managementModule.directive("chargeitemImportUploadFileView", ["$log", "$q", "$timeout", "aresNotification", "loginContext", "exportSvc", "aresDialog", function(n, t, i, r, u, f, e) { "use strict"; return { restrict: "E", replace: !0, templateUrl: "/app/management/components/chargeitem-import-upload-file/chargeitem-import-upload-file-view.html", link: function(n, t) { var s = function() { i(function() { t.find("#chargeItemImportNewDialogFileInput").click() }) },
                h = function() { n.isClearData ? e.confirm("警告", "采用全量形式导入将删除当前的所有收费项数据且不能恢复，确认要执行该操作吗?").then(function() { o() }) : (n.isClearData = !1, o()) },
                o = function() { var t = n.data,
                        o, i, s, h;
                    t ? (n.isDisabled = !0, o = t.files[0].name, i = o.split("."), i[i.length - 1] == "xls" || i[i.length - 1] == "xlsx" ? (n.fileName = o, s = u.apiToken, h = u.tokenType, t.url = u.apiHost + "/api/v1/document/import/chargeitem?fullupdate=" + n.isClearData.toString(), t.headers = t.headers || {}, t.headers.Authorization = h + " " + s, t.submit()) : (f(), r.error("文件格式不对"))) : e.warn("提示", "请选择要导入的文件！") },
                c = function(t, i) { var r = parseInt(i.loaded / i.total * 100, 10);
                    n.progress = r },
                l = function(t, i) { n.data = i; var r = i.files[0].name;
                    $("#scmProductImportNewDialogFileName").val(r) },
                a = function() { f();
                    r.success("上传成功");
                    n.cancel() },
                v = function() { n.isDisabled = !1;
                    n.progress = 100;
                    n.isUploadFailed = !0 },
                y = function() { f() },
                f = function() { n.isDisabled = !1;
                    n.fileName = null;
                    n.progress = 0;
                    n.isUploadFailed = !1 };
            (function() { n.selectFile = s;
                n.startUpload = h;
                n.uploadProgressed = c;
                n.uploadFinished = a;
                n.uploadFailed = v;
                n.addUpload = l;
                n.cancelUpload = y;
                n.isDisabled = !1 })() } } }]);
managementModule.controller("ChargeItemImportUploadFileCtrl", ["$log", "$q", "$scope", "$timeout", "enums", "backgroundTaskSvc", "aresNotification", "aresDialog", "$modalInstance", function(n, t, i, r, u, f, e, o, s) { "use strict"; var h = function() { s.dismiss("cancel") };
    (function() { i.cancel = h })() }]);
managementModule.directive("followupAutoRuleCondView", ["$modal", "$q", "$timeout", "dataDicSvc", "followupSvc", "managementDialogUtil", "practiceSvc", function(n) { "use strict"; return { restrict: "E", replace: !0, templateUrl: "/app/management/components/followup-auto-rule-cond/followup-auto-rule-cond-view.html", scope: { editable: "=", condType: "=", savedFollowupRuleConds: "=", onChange: "&" }, link: function(t) { var i, r = function() { t.showAll = !0; var i = n.open({ animation: !0, backdrop: "static", template: "<item-dialog-view><\/item-dialog-view>", controller: "ItemDialogCtrl", windowClass: "followup-rule-edit-add-dialog", resolve: { host: function() { return { type: t.condType, list: angular.copy(t.savedFollowupRuleConds) } } } });
                    i.result.then(function(n) { t.savedFollowupRuleConds.length = 0;
                        t.condType == "transactioncode" ? n.obj.forEach(n => t.savedFollowupRuleConds.push({ id: n.id, itemName: n.name || n.itemName, condType: t.condType })) : n.obj.forEach(n => t.savedFollowupRuleConds.push({ id: n.id, itemName: n.itemName, condType: t.condType }));
                        typeof t.onChange == "function" && t.onChange() }) },
                u = function(n) { t.savedFollowupRuleConds.splice(n, 1) },
                f = function() { t.ruleCondSelected ? i && i.forEach(n => t.savedFollowupRuleConds.push(n)) : (i = angular.copy(t.savedFollowupRuleConds), t.savedFollowupRuleConds.length = 0) };
            (function() { t.chooseFollowupRuleCond = r;
                t.removeRuleCond = u;
                t.onRuleCondClick = f;
                t.$watch("savedFollowupRuleConds", function() { t.savedFollowupRuleConds && t.savedFollowupRuleConds.length > 0 && (t.ruleCondSelected = !0) });
                t.showAll = !1;
                t.condType == "chargeItem" ? t.labelShowName = "收费项目" : t.condType == "chargeCategory" ? t.labelShowName = "收费小类" : t.condType == "transactioncode" ? t.labelShowName = "预约项目" : t.condType == "apptCategory" && (t.labelShowName = "预约大类") })() } } }]);
managementModule.controller("ApptPerformanceCtrl", ["$log", "$filter", "$scope", "$modal", "$q", "officeSvc", "appointmentSvc", "reportUtil", "dataDicSvc", function(n, t, i, r, u, f, e, o, s) { "use strict"; var h, l = function() { var n = Ares.today(),
                t = moment(n).add(-1, "week").toDate();
            h = { startDate: t, endDate: n };
            i.timeSpan = _.clone(h) },
        a = function() { var t = i.timeSpan.startDate || h.startDate,
                n = i.timeSpan.endDate || h.endDate;
            n = moment(n).add(1, "day").toDate();
            i.createId && i.createId != "全部" || (i.createId = -1);
            o.checkReportDayLimited(t, n).then(function() { e.getApptPer(t, n, i.createId, i.selectTenant).success(function(n) { i.pageData = n }) }) },
        c = function(n) { i.pageIndex = n;
            a(i.pageIndex, i.pageSize) },
        v = function() { c(1) },
        y = function() { var n = u.defer(); return i.$root.isRegularChain ? s.sharedOfficeDic.load().then(function(t) { var r = t.length;
                r > 1 ? (i.selectTenant = !0, i.isShowRadioBtn = !0) : (i.selectTenant = !1, i.isShowRadioBtn = !1);
                n.resolve(!0) }) : (i.selectTenant = !1, n.resolve(!0)), n.promise };
    (function() { i.pageIndex = 1;
        i.pageSize = 100;
        i.maxPageCount = 10;
        i.onPageChanged = c;
        i.search = v;
        y().then(function() { c(1) });
        l() })() }]);
managementModule.controller("ApptTransferredCtrl", ["$log", "$filter", "$scope", "$modal", "$q", "formatUtil", "reportSvc", function(n, t, i, r, u, f, e) { "use strict"; var o = function() { var n = Ares.today(),
                r = moment(n).add(-1, "d").toDate(),
                t = { pageIndex: 1, pageSize: 10, startDate: n, endDate: n, searchText: "", fromDoctorId: i.fromDoctorId, fromDoctorDepartment: i.fromDoctorDepartment, toDoctorId: i.toDoctorId, toDoctorDepartment: i.toDoctorDepartment };
            i.searchCriteria = t },
        s = function() { var n = u.defer(); return i.searchCriteria.startDate = moment(i.searchCriteria.startDate).format("YYYY-MM-DD"), i.searchCriteria.endDate = moment(i.searchCriteria.endDate).format("YYYY-MM-DD"), e.getTransferredAppintment(i.searchCriteria).success(function(t) { h(t);
                i.searchResult = t;
                n.resolve({ total: t.totalCount, data: t.items }) }), n.promise },
        h = function(n) { f.formatList(n.items, { startTime: "longDateTime", birth: "ageStr", sex: "sexStr", fromDoctorId: "doctorName", toDoctorId: "doctorName" }) };
    (function() { i.search = s;
        o() })() }]);
managementModule.controller("AttendanceRulesettingDialogCtrl", ["$log", "$filter", "$scope", "$modalInstance", "practiceSvc", "aresDialog", "host", function(n, t, i, r, u, f, e) { "use strict";
    i.cancel = function() { r.dismiss("cancel") };
    i.ok = function() { if (i.currentRuleDetail) { if (i.existList)
                    for (var n = 0; n < i.existList.length; ++n)
                        if (i.existList[n].name == i.currentRuleDetail.name) { f.warn("错误", "名称已被使用，请改名"); return } i.currentRuleDetail.id > 0 ? u.updateScheduleRuleDetail(i.currentRuleDetail).success(function() { f.info("信息", "保存成功！");
                    r.close(i.currentRuleDetail) }) : u.createScheduleRuleDetail(i.currentRuleDetail).success(function() { f.info("信息", "保存成功！");
                    r.close(i.currentRuleDetail) }) } },
        function() { i.existList = e.existList;
            e.id > 0 ? u.getScheduleRuleDetail(e.id).success(function(n) { n.startTime = moment(n.startTime).format("HH:mm");
                n.endTime = moment(n.endTime).format("HH:mm");
                i.currentRuleDetail = n; var t = $("#palette").data("kendoColorPicker");
                t.value(i.currentRuleDetail.scheduleColor) }) : i.currentRuleDetail = { id: 0, name: "", weekDayType: "AllWeekDays", startTime: "08:00", endTime: "18:00", scheduleColor: "#FFD9D9", status: "ATTEND" } }() }]);
managementModule.controller("AttendanceRulesettingCtrl", ["$log", "$filter", "$scope", "$modal", "appNav", function() { "use strict";
    (function() {})() }]);
managementModule.controller("AttendanceStaffCtrl", ["$log", "$filter", "$scope", "$modal", "appNav", function() { "use strict";
    (function() {})() }]);
managementModule.controller("consultPerformanceCtrl", ["$log", "$scope", "$q", "$modal", "reportSvc", "practiceSvc", "loginContext", "patientUtil", "officeSvc", "moduleOptionProvider", "officeSelectorUtil", "aresNotification", function(n, t, i, r, u, f, e, o, s, h, c, l) { "use strict"; var a = function() { if (t.searchCriteria.startDate = moment(t.timeSpan.startDate).format("YYYY-MM-DD"), t.searchCriteria.endDate = moment(t.timeSpan.endDate).add(1, "days").format("YYYY-MM-DD"), !t.timeSpan.startDate || moment(t.timeSpan.startDate).add(12, "month") < moment(t.timeSpan.endDate)) { l.error("一次最多查询一年数据"); return } if (t.isGroup && t.selectedOfficeIds == e.officeId) { l.error("请选择门店"); return } t.searchCriteria.officeIds = t.selectedOfficeIds;
            t.searchCriteria.departments == "全部" && (t.searchCriteria.departments = "");
            u.getConsultPerformanceList(t.searchCriteria).success(function(n) { t.pageData = n }) },
        v = function() { s.getSelfAndChildOfficesByGroupId(e.officeId, h.isDescendantDataOpen()).success(function(n) { t.officeTreeData = c.setId(n) }) };
    (function() { t.search = a;
        t.loadOfficeTreeData = v })() }]);
managementModule.controller("ConsultantWorkSummaryReportCtrl", ["$log", "$scope", "$modal", "reportSvc", "formatUtil", "reportUtil", "$q", "userOptionSvc", "gridOptionUtil", "permissionProvider", "aresNotification", "loginContext", function(n, t, i, r, u, f, e, o, s, h, c, l) { "use strict"; var a, b = function() { a = f.getDefaultTimeSpan(!0);
            t.timeSpan = _.clone(a) },
        v = function() { var n = f.getStartEndTime(t),
                i = t.isPrivate && l.providerJob == "咨询师" ? l.providerId : -1,
                e = t.job === "咨询师" ? 1 : 2;
            f.checkReportDayLimited(n.start, n.end).then(function() { t.queryType === "按收费记录统计" || t.job === "牙医助理" ? (t.showConsultantGrid = !0, p().then(function() { var f = { startDate: n.start, endDate: n.end, providerId: i, providerType: e, tagIds: t.getTagIds(), orderMinDiscount: t.orderMinDiscount, orderMaxDiscount: t.orderMaxDiscount, selectCode: t.selectCode, transactionIds: t.transactionCodes, privateTag: t.privateTag, isDealed: t.isDealed };
                    r.getProviderWorkSummaryReport(f).success(function(n) { t.payTypes = [];
                        angular.forEach(n, function(n) { if (n.tagStr && (n.tagStr = n.tagStr.substring(0, n.tagStr.length - 1), n.tagStr = n.tagStr.substring(1)), n.startTime = moment(n.startTime).format("YYYY-MM-DD HH:mm"), n.payDateTime = moment(n.payDateTime).format("YYYY-MM-DD HH:mm"), u.formatAppt(n), n.patientTags && n.patientTags.tags) { var i = "";
                                angular.forEach(n.patientTags.tags, function(n) { i = i + n.itemName + "," });
                                i && (i = i.substring(0, i.length - 1));
                                n.patientTagStr = i } n.discount = n.discount + "%";
                            n.isChargedStr = n.isCharged ? "已充值" : "未充值";
                            t.payTypes.push(n.payType);
                            t.payTypes.push(n.payType2);
                            t.payTypes.push(n.payType3);
                            n[n.payType] = n.actualPrice1;
                            n[n.payType2] = n.actualPrice2;
                            n[n.payType3] = n.actualPrice3 });
                        k(n);
                        t.pageData = n }) })) : w().then(function() { t.showConsultantGrid = !1;
                    r.getProviderWorkTxPlanSummaryReport(n.start, n.end, i, e).success(function(n) { angular.forEach(n, function(n) { n.startTime = moment(n.startTime).format("YYYY-MM-DD HH:mm");
                            n.recordCreatedTimeStr = moment(n.recordCreatedTime).format("YYYY-MM-DD HH:mm");
                            n.statusStr = n.status === 1 ? "进行中" : "已完成" });
                        t.txPlanSummary = n }) }) }) },
        k = function(n) { var r = [],
                e, f, o, i, u; for (t.gridColumns = [], t.aggregate = [], t.aggregate.push({ field: "planPrice", aggregate: "sum" }, { field: "consultantName", aggregate: "count" }, { field: "actualPrice", aggregate: "sum" }, { field: "actualAmount", aggregate: "sum" }, { field: "performance", aggregate: "sum" }), e = 1, u = 0; u < t.payTypes.length; ++u) { for (f = t.payTypes[u], o = !1, i = 0; i < r.length; i++)
                    if (r[i].type == f) { o = !0; break } o == !1 && f != null && f !== "" && (r.push({ index: "p" + e, type: f }), e++) } for (i = 0; i < r.length; i++) { for (u = 0; u < n.length; u++) n[u][r[i].index] || (n[u][r[i].index] = 0), n[u][r[i].type] && (n[u][r[i].index] = n[u][r[i].type]);
                t.gridColumns.push({ field: r[i].index, title: r[i].type, headerTemplate: r[i].type, width: "150px", format: "{0:n}", aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#", hidden: !1 });
                t.aggregate.push({ field: r[i].index, aggregate: "sum" }) } },
        y = function() { if ((t.queryType === "按收费记录统计" || t.job === "牙医助理") && (t.orderMinDiscount == null || _.isUndefined(t.orderMinDiscount) || t.orderMinDiscount.toString() == "" || t.orderMaxDiscount == null || _.isUndefined(t.orderMaxDiscount) || t.orderMaxDiscount.toString() == "")) { c.error("请填写正确的整单折扣率！"); return } v() },
        p = function() { var n = e.defer(); return o.getUserOption(s.keys.consultantWorkSummaryGridOption).then(function(i) { t.showColumns = i != null ? i : "^";
                n.resolve(!0) }), n.promise },
        d = function(n) { var r = e.defer(),
                i = t.showColumns.split(","); return i = _.filter(i, function(n) { return n.indexOf("undefined") === -1 }), s.formatColumns(n, i), r.resolve(n), r.promise },
        w = function() { var n = e.defer(); return o.getUserOption(s.keys.consultantWorkTxPlanSummaryReport).then(function(i) { t.showTxColumns = i != null ? i : "^";
                n.resolve(!0) }), n.promise },
        g = function(n) { var r = e.defer(),
                i = t.showTxColumns.split(","); return i = _.filter(i, function(n) { return n.indexOf("undefined") === -1 }), s.formatColumns(n, i), r.resolve(n), r.promise },
        nt = function() { v() },
        tt = function() { var n = angular.copy(t.transactionItems),
                r;
            n || (n = []);
            r = i.open({ animation: !0, backdrop: "static", template: "<item-dialog-view><\/item-dialog-view>", controller: "ItemDialogCtrl", windowClass: "followup-rule-edit-add-dialog", resolve: { host: function() { return { type: "transactioncode", list: n } } } });
            r.result.then(function(n) { var u, r, f, e, i; if (n) { for (u = n.isSaveAll ? ["全部"] : _.pluck(n.obj, "itemName"), r = "", i = 0; i < u.length; i++) { if (r.length > 10) { r += "..."; break } r += u[i] + "," } for (t.transactionCodeNames = r == "" || r == "全部," ? "全部" : r, angular.forEach(n.obj, function(n) { n.condType = "transactioncode" }), f = n.isSaveAll ? ["全部"] : _.pluck(n.obj, "id"), e = "", i = 0; i < f.length; i++) e += f[i] + ",";
                    t.transactionItems = n.obj;
                    t.transactionCodes = e } }) };
    (function() { t.privateTag = "";
        t.orderMinDiscount = 0;
        t.orderMaxDiscount = 100;
        t.selectCode = "";
        t.toggleStateSelection = nt;
        t.openTransactionItemsDialog = tt;
        t.defaultSelect = !0;
        t.search = y;
        t.queryType = "按收费记录统计";
        t.showQueryType = t.job === "咨询师";
        t.isShowExcelBtn = t.job === "咨询师" ? h.isAllowed(t.isPrivate ? "myReport.allExport" : "performance.consultantWorkSummaryExcel") : h.isAllowed("performance.assistantWorkSummaryExcel");
        t.loadColumnsOption = p;
        t.generateColumns = d;
        t.loadTxColumnsOption = w;
        t.generateTxColumns = g;
        b();
        y();
        t.$watch("defaultSelect", function() { t.timeSpan = f.getDefaultTimeSpan(t.defaultSelect) }) })() }]);
managementModule.controller("FollowupBorwserCtrl", ["$q", "$scope", "reportSvc", "aresDialog", function(n, t, i, r) { "use strict"; var u = function(u) { var e = n.defer(),
                f = t.getSearchCriteria(); return f.pageSize = u ? 1 : f.pageSize, f.officeIds && f.officeIds.length != 0 ? i.getFollowupDoctorPgeReport(f).success(function(n) { e.resolve(n) }) : (r.info("提示", "请至少选择一个机构"), e.reject()), e.promise },
        f = function() { var n = t.getSearchCriteria();
            i.createFollowupListBackgroundReport(n).success(function(n) { var t = n.isSucceed ? n.hasTaskCancelled ? "后台报表'" + n.newTask.reportName + "'已创建！（已取消10分钟内同类报表）" : "后台报表'" + n.newTask.reportName + "'已创建！" : "已存在处理的同类型的报表（10分钟内只能创建一个同类型报表）！";
                r.info("信息", t) }) };
    (function() { t.createFollowupListBackgroundReport = f;
        t.getPagedFollowups = u })() }]);
managementModule.controller("GroupPerformanceChargeCategoryCtrl", ["$log", "$filter", "$scope", "$rootScope", "eventAggregator", "$modal", "productSvc", "aresDialog", "permissionProvider", "dataDicSvc", "organizationSvc", "inventoryProductSvc", "gridOptionUtil", "systemitemSvc", "officeSvc", "moduleOptionProvider", "aresNotification", "formatUtil", "multiOfficeDataDic", "$q", "reportUtil", "enums", "officeSelectorUtil", "loginContext", "practiceSvc", "providerSvc", "reportSvc", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y, p, w, b, k, d, g, nt, tt, it, rt, ut, ft) { "use strict"; var et = function() { var n = d.defer(),
                t = ""; return i.selectedOfficeIds ? (t = i.selectedOfficeIds.join(), i.criteria = { providerIdStr: i.selectCategory ? i.getProviders() : null, departmentNameStr: i.selectCategory ? null : i.getProviders(), providerType: "doctor", SuperType: i.selectSuperType, startTime: i.timeSpan.startDate ? moment(i.timeSpan.startDate).format("YYYY-MM-DD") : moment(Ares.today()).format("YYYY-MM-DD"), endTime: i.timeSpan.endDate ? moment(i.timeSpan.endDate).add(1, "day").format("YYYY-MM-DD") : moment(Ares.today()).add(1, "day").format("YYYY-MM-DD"), selectPriceType: i.selectActualPrice, officeIds: t }, i.selectedOfficeIds.length == 1 ? g.checkReportDayLimited(i.criteria.startDate, i.criteria.endDate).then(function() { ft.getGroupDoctorChargeCategoryReportData(i.criteria).success(function(t) { var r = t.dataLoad;
                    i.showOverflowWarning = t.overflow;
                    i.count = r ? r.length : 0;
                    i.pageData = r;
                    n.resolve(!0) }).error(function(t) { o.error("发生了一个错误", t.message);
                    n.resolve(!1) }) }) : i.selectedOfficeIds.length > 5 ? w.error("一次最多查询五个门店的数据") : !i.timeSpan.startDate || moment(i.timeSpan.startDate).add(1, "month") < moment(i.timeSpan.endDate) ? w.error("一次最多查询一个月的数据") : g.checkReportDayLimited(i.criteria.startDate, i.criteria.endDate).then(function() { ft.getGroupDoctorChargeCategoryReportData(i.criteria).success(function(t) { var r = t.dataLoad;
                    i.showOverflowWarning = t.overflow;
                    i.count = r ? r.length : 0;
                    i.pageData = r;
                    n.resolve(!0) }).error(function(t) { o.error("发生了一个错误", t.message);
                    n.resolve(!1) }) })) : w.error("请选择诊所"), n.promise },
        ot = function() { i.gridColumns = [{ hidden: !1, field: "officeName", title: "诊所名称", width: "80px" }, { hidden: !1, field: "department", title: "科室", width: "80px" }, { hidden: !1, field: "providerName", title: "医生", width: "200px", footerTemplate: "总计" }];
            angular.forEach(i.chargeCategorys, function(n, t) { i.gridColumns.push({ hidden: !1, field: "column" + t, title: n, headerTemplate: n, attributes: { style: "padding: 0" }, width: "120px", format: "{0:n}", aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'n2')#" }) });
            i.gridColumns.push({ hidden: !1, field: "sumPrice", title: "金额", headerTemplate: "金额", attributes: { style: "padding: 0px" }, width: "120px", format: "{0:n}", aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'n2')#" }) },
        st = function() { var a = [],
                t = [],
                v = _.groupBy(i.pageData, function(n) { return n.providerId + "," + n.officeId }),
                y, f, n, u, b, r, k, d, g, nt, tt, it, l, rt, ut; for (y in v) { f = v[y];
                n = {};
                n.providerName = f[0].providerName;
                n.department = f[0].department;
                n.officeName = f[0].officeName; var p = 0,
                    w = 0,
                    e = 0,
                    s = 0,
                    h = 0,
                    c = 0,
                    o = 0; for (u = 0; u < i.chargeCategorys.length; u++) b = i.chargeCategorys[u], r = _.filter(f, function(n) { return n.itemName === b }), r && r.length > 0 ? (k = i.selectActualPrice ? _.pluck(r, "actualPrice") : _.pluck(r, "planPrice"), d = _.pluck(r, "planPrice"), w = w + _.reduce(d, function(n, t) { return n + t }, 0), g = _.pluck(r, "overdue"), e = e + _.reduce(g, function(n, t) { return n + t }, 0), nt = _.pluck(r, "discountPrice"), s = s + _.reduce(nt, function(n, t) { return n + t }, 0), tt = _.pluck(r, "actualPrice"), h = h + _.reduce(tt, function(n, t) { return n + t }, 0), it = _.pluck(r, "payAmountByVoucher"), l = _.reduce(it, function(n, t) { return n + t }, 0), o = o + l, rt = _.pluck(r, "deductPrice"), c = c + _.reduce(rt, function(n, t) { return n + t }, 0), n["column" + u] = _.reduce(k, function(n, t) { return n + t }, 0) - l, p += n["column" + u]) : n["column" + u] = 0, ut = _.find(t, function(n) { return n.field == "column" + u }), ut || t.push({ field: "column" + u, aggregate: "sum" });
                n.overduePrice = e;
                n.actualPrice = h - o;
                n.accountsReceivable = n.actualPrice + e;
                n.achievement = n.accountsReceivable;
                n.performanceIncome = n.actualPrice;
                n.deductPrice = c;
                n.realDiscountPrice = s + o;
                n.sumPrice = p;
                n.totalPrice = n.realDiscountPrice + n.accountsReceivable;
                a.push(n) } t.push({ field: "sumPrice", aggregate: "sum" });
            t.push({ field: "totalPrice", aggregate: "sum" });
            t.push({ field: "realDiscountPrice", aggregate: "sum" });
            t.push({ field: "accountsReceivable", aggregate: "sum" });
            t.push({ field: "actualPrice", aggregate: "sum" });
            t.push({ field: "overduePrice", aggregate: "sum" });
            t.push({ field: "achievement", aggregate: "sum" });
            t.push({ field: "performanceIncome", aggregate: "sum" });
            t.push({ field: "deductPrice", aggregate: "sum" });
            i.dataSource = a;
            i.aggregate = t },
        ht = function() { var t = d.defer(),
                n = []; return angular.forEach(i.pageData, function(t) { t.itemName || (t.itemName = i.selectSuperType == 0 ? "未知大类" : i.selectSuperType == 1 ? "未知小类" : "未知收费类型");
                n.indexOf(t.itemName) === -1 && n.push(t.itemName) }), i.chargeCategorys = n, t.resolve(!0), t.promise },
        ct = function() { et().then(function() { ht().then(function() { ot();
                    st();
                    i.initGrid() }) }) },
        lt = function() { y.getSelfAndChildOfficesByGroupId(it.officeId, p.isDescendantDataOpen()).success(function(n) { i.officeTreeData = tt.setId(n) }) },
        at = function(n) { i.selectedOfficeIds = _.pluck(n, "officeId"); var t = it.officeId;
            i.selectedOfficeIds && i.selectedOfficeIds.length == 1 ? (i.isEnabled = !0, t = i.selectedOfficeIds) : i.isEnabled = !1;
            i.initOfficeDepartmentsSelect(t);
            i.initOfficeProvidersSelect(t) },
        vt = function(n) { return rt.getDepartmentByOfficeId(n) },
        yt = function(n) { var t = d.defer(); return ut.getWorkProvidersByOffice(n).success(function(n) { n = _.filter(n, function(n) { return n.job === "医生" });
                t.resolve(n) }), t.promise },
        pt = function() { i.timeSpan = { startDate: moment(Ares.today()), endDate: moment(Ares.today()) };
            lt() };
    (function() { i.selectActualPrice = !0;
        i.selectCategory = !0;
        i.selectSuperType = 2;
        i.showOverflowWarning = !1;
        i.getOfficeProviders = yt;
        i.getOfficeDepartments = vt;
        pt();
        i.isShowExcelBtn = s.isAllowed("performance.doctorChargeCategroyExcel");
        i.onOfficeSelected = at;
        i.search = ct })() }]);
managementModule.controller("ManagementHomeCtrl", ["$log", "$scope", "dataDicSvc", function() { "use strict";
    (function() {})() }]);
managementModule.controller("PerformanceChargeCategoryCtrl", ["$log", "$timeout", "$scope", "$modal", "practiceSvc", "reportSvc", "aresDialog", "$q", "providerSvc", "loginContext", "reportUtil", "permissionProvider", "gridOptionUtil", "aresNotification", function(n, t, i, r, u, f, e, o, s, h, c, l, a) { "use strict"; var y = function() { i.timeSpan = { startDate: moment(Ares.today()), endDate: moment(Ares.today()) } },
        p = function(n) { var t = o.defer(); return i.criteria = { providerIdStr: i.selectCategory ? i.getProviders() : null, departmentNameStr: i.selectCategory ? null : i.getProviders(), providerType: i.job, SuperType: i.selectSuperType, startTime: i.timeSpan.startDate ? moment(i.timeSpan.startDate).format("YYYY-MM-DD") : moment(Ares.today()).format("YYYY-MM-DD"), endTime: i.timeSpan.endDate ? moment(i.timeSpan.endDate).add(1, "day").format("YYYY-MM-DD") : moment(Ares.today()).add(1, "day").format("YYYY-MM-DD"), selectPriceType: i.selectActualPrice }, n === "load" && (i.criteria.providerIdStr = null, i.criteria.departmentNameStr = null), c.checkReportDayLimited(i.criteria.startDate, i.criteria.endDate).then(function() { f.getDoctorChargeCategoryReportData(i.criteria).success(function(n) { var r = n.dataLoad;
                    i.showOverflowWarning = n.overflow;
                    i.count = r ? r.length : 0;
                    i.pageData = r;
                    t.resolve(!0) }).error(function(n) { e.error("发生了一个错误", n.message);
                    t.resolve(!1) }) }), t.promise },
        w = function() { return u.getDepartmentByOfficeId(h.officeId) },
        b = function() { var n = o.defer(); return s.getOtherProvider().success(function(t) { t = _.filter(t, function(n) { return n.job === i.jobName });
                n.resolve(t) }), n.promise },
        k = function() { var t = o.defer(),
                n = []; return angular.forEach(i.pageData, function(t) { t.itemName || (t.itemName = i.selectSuperType == 0 ? "未知大类" : i.selectSuperType == 1 ? "未知小类" : "未知收费类型");
                n.indexOf(t.itemName) === -1 && n.push(t.itemName) }), i.chargeCategorys = n, t.resolve(!0), t.promise },
        d = function() { y() },
        g = function(n) { var i = n.aggregates.totalPrice.sum,
                t = "科室:" + n.value; return t += "   总金额:" + Ares.priceToFixed(i), t += "   总实收金额:" + Ares.priceToFixed(n.aggregates.actualPrice.sum), t += "   总减免金额:" + Ares.priceToFixed(n.aggregates.realDiscountPrice.sum), t + ("   总欠费金额:" + Ares.priceToFixed(n.aggregates.overduePrice.sum)) },
        v = function() { i.gridColumns = [{ hidden: !0, field: "department", title: "科室", width: "80px", groupHeaderTemplate: g }, { hidden: !1, field: "providerName", title: i.jobName, width: "200px", footerTemplate: "总计" }];
            angular.forEach(i.chargeCategorys, function(n, t) { i.gridColumns.push({ hidden: !1, field: "column" + t, title: n, headerTemplate: n, attributes: { style: "padding: 0" }, width: "120px", format: "{0:n}", aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'n2')#" }) });
            i.gridColumns.push({ hidden: !1, field: "sumPrice", title: "金额", headerTemplate: "金额", attributes: { style: "padding: 0px" }, width: "120px", format: "{0:n}", aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'n2')#" });
            i.gridColumns.push({ hidden: !0, field: "totalPrice", title: "总金额", headerTemplate: "总金额", attributes: { style: "padding: 0px" }, width: "120px", format: "{0:n}", aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'n2')#" });
            i.gridColumns.push({ hidden: !0, field: "realDiscountPrice", title: "减免金额", headerTemplate: "减免金额", attributes: { style: "padding: 0px" }, width: "120px", format: "{0:n}", aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'n2')#" });
            i.gridColumns.push({ hidden: !0, field: "accountsReceivable", title: "应收金额", headerTemplate: "应收金额", attributes: { style: "padding: 0px" }, width: "120px", format: "{0:n}", aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'n2')#" });
            i.gridColumns.push({ hidden: !0, field: "actualPrice", title: "实收金额", headerTemplate: "实收金额", attributes: { style: "padding: 0px" }, width: "120px", format: "{0:n}", aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'n2')#" });
            i.gridColumns.push({ hidden: !0, field: "overduePrice", title: "欠费金额", headerTemplate: "欠费金额", attributes: { style: "padding: 0px" }, width: "120px", format: "{0:n}", aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'n2')#" });
            i.gridColumns.push({ hidden: !0, field: "achievement", title: "业绩收入", headerTemplate: "业绩收入", attributes: { style: "padding: 0px" }, width: "120px", format: "{0:n}", aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'n2')#" });
            i.gridColumns.push({ hidden: !0, field: "performanceIncome", title: "绩效收入", headerTemplate: "绩效收入", attributes: { style: "padding: 0px" }, width: "120px", format: "{0:n}", aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'n2')#" });
            i.gridColumns.push({ hidden: !0, field: "deductPrice", title: "划扣业绩收入", headerTemplate: "划扣业绩收入", attributes: { style: "padding: 0px" }, width: "140px", format: "{0:n}", aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'n2')#" }) },
        nt = function() { var n = o.defer(),
                t = a.keys.chargeCategroyDoctorReportGridOption; return t = i.job === "doctor" ? a.keys.chargeCategroyDoctorReportGridOption : i.job === "consult" ? a.keys.chargeCategroyConsultReportGridOption : a.keys.chargeCategroyNurseReportGridOption, a.loadColumnsOption(t).then(function(t) { v();
                i.showColumns = t;
                i.showColumns.length > 0 && angular.forEach(i.gridColumns, function(n) { var t = _.find(i.showColumns, function(t) { return t == n.field });
                    n.hidden = t ? !1 : n.hidden });
                n.resolve(!0) }), n.promise },
        tt = function() { var a = [],
                e = [],
                v = [],
                t = [],
                u, f, b, r, k, d, g, nt, tt, it, rt, ut; for (angular.forEach(i.pageData, function(n) { var t = n.providerId + "|" + n.providerName;
                    e.indexOf(t) === -1 && (e.push(t), v.push(n.department)) }), u = 0; u < e.length; u++) { var n = {},
                    ft = e[u].split("|")[0],
                    y = e[u].split("|")[1];
                n.providerName = y;
                n.department = v[u]; var p = 0,
                    w = 0,
                    o = 0,
                    h = 0,
                    c = 0,
                    l = 0,
                    s = 0; for (f = 0; f < i.chargeCategorys.length; f++) b = i.chargeCategorys[f], r = _.filter(i.pageData, function(n) { return n.itemName === b && n.providerId == ft && n.providerName === y }), r && r.length > 0 ? (k = i.selectActualPrice ? _.pluck(r, "actualPrice") : _.pluck(r, "planPrice"), d = _.pluck(r, "planPrice"), w = w + _.reduce(d, function(n, t) { return n + t }, 0), g = _.pluck(r, "overdue"), o = o + _.reduce(g, function(n, t) { return n + t }, 0), nt = _.pluck(r, "discountPrice"), h = h + _.reduce(nt, function(n, t) { return n + t }, 0), tt = _.pluck(r, "actualPrice"), c = c + _.reduce(tt, function(n, t) { return n + t }, 0), it = _.pluck(r, "payAmountByVoucher"), rt = _.reduce(it, function(n, t) { return n + t }, 0), s = s + rt, ut = _.pluck(r, "deductPrice"), l = l + _.reduce(ut, function(n, t) { return n + t }, 0), n["column" + f] = _.reduce(k, function(n, t) { return n + t }, 0), p += n["column" + f]) : n["column" + f] = 0, u === 0 && t.push({ field: "column" + f, aggregate: "sum" });
                n.overduePrice = o;
                n.actualPrice = c - s;
                n.accountsReceivable = n.actualPrice + o;
                n.achievement = n.accountsReceivable;
                n.performanceIncome = n.actualPrice;
                n.deductPrice = l;
                n.realDiscountPrice = h + s;
                n.sumPrice = p;
                n.totalPrice = n.realDiscountPrice + n.accountsReceivable;
                a.push(n);
                u === 0 && (t.push({ field: "sumPrice", aggregate: "sum" }), t.push({ field: "totalPrice", aggregate: "sum" }), t.push({ field: "realDiscountPrice", aggregate: "sum" }), t.push({ field: "accountsReceivable", aggregate: "sum" }), t.push({ field: "actualPrice", aggregate: "sum" }), t.push({ field: "overduePrice", aggregate: "sum" }), t.push({ field: "achievement", aggregate: "sum" }), t.push({ field: "performanceIncome", aggregate: "sum" }), t.push({ field: "deductPrice", aggregate: "sum" })) } i.dataSource = a;
            i.aggregate = t },
        it = function(n) { p(n).then(function() { k().then(function() { v();
                    tt() }) }) };
    (function() { i.selectActualPrice = !0;
        i.selectCategory = !0;
        i.selectSuperType = 1;
        i.showOverflowWarning = !1;
        i.search = it;
        i.isShowExcelBtn = !1;
        i.loadColumnsOption = nt;
        i.job === "doctor" ? (i.jobName = "医生", i.isShowExcelBtn = l.isAllowed("performance.doctorChargeCategroyExcel"), i.isDoctor = !0) : i.job === "consult" ? (i.jobName = "咨询师", i.isShowExcelBtn = l.isAllowed("performance.consultantChargeCategoryExcel"), i.isDoctor = !1) : (i.jobName = "护士", i.isShowExcelBtn = l.isAllowed("performance.nurseChargeCategroyExcel"), i.isDoctor = !1);
        i.printSetting = { title: "医生收费大类", payDate: null, payType: "", printTime: null };
        i.getOfficeDepartments = w;
        i.getOfficeProviders = b;
        d() })() }]);
managementModule.controller("PerformanceChargeClassCtrl", ["$log", "$filter", "$scope", "$modal", "appNav", "reportSvc", "practiceSvc", function(n, t, i, r, u, f, e) { "use strict"; var o, c = function() { var n = Ares.today(),
            t = moment(Ares.today()).startOf("month").toDate();
        o = { startDate: t, endDate: n };
        i.timeSpan = _.clone(o) };
    i.chargeOrderSimpleDetailList = {};
    i.chargeOrder = {}; var l = function() { var t = i.timeSpan.startDate || o.startDate,
                n = i.timeSpan.endDate || o.endDate;
            n = moment(n).add(1, "day").toDate();
            e.getChargeOrderSimpleDetail(t, n).success(function(r) { for (var u = 0; u < r.length; u++) r[u].totalPrice = r[u].totalPrice;
                i.chargeOrderSimpleDetailList = r;
                e.getChargeOrderByTime(t, n).success(function(r) { i.chargeOrder = r;
                    e.getChargeCategory().success(function(r) { i.chargeItemCatagories = r;
                        f.getChargeDetailReport(t, n).success(function(r) { for (var u = 0; u < r.length; u++) r[u].finalprice = r[u].finalprice;
                            i.chargeDetailList = r;
                            f.getCdtChargeItem(t, n).success(function(n) { i.chargeDetailListCdt = n;
                                a() }) }) }) }) }) },
        a = function() { var c = [],
                y = [],
                b, u, a, v, k, tt, d, w, g, h, nt, r, it, e, f, n, t; if (y = [{ field: "doctorName", title: "医生", width: "80px" }], i.chargeDetailList) { for (b = { finalprice: 0, actualprice: 0 }, u = {}, n = 0; n < i.chargeItemCatagories.length; n++) i.chargeItemCatagories[n].index = "p" + (n + 1), b[i.chargeItemCatagories[n].index] = 0, y.push({ field: i.chargeItemCatagories[n].index, title: i.chargeItemCatagories[n].itemName, headerTemplate: i.chargeItemCatagories[n].itemName, width: "80px", format: "{0:n}" });
                y.push({ field: "finalprice", title: "应收总额(折扣后)", width: "80px", format: "{0:n}" });
                y.push({ field: "actualprice", title: "实收总额", width: "80px", format: "{0:n}" }); var o = [],
                    p = [],
                    l = []; for (t = 0; t < i.chargeOrder.length; ++t)
                    if (r = i.chargeOrder[t], r.doctorId == 0) p.push(r);
                    else { for (a = !1, n = 0; n < o.length; n++)
                            if (o[n].name == r.doctorName) { a = !0;
                                o[n].children.push(r); break } a == !1 && (v = { name: r.doctorName, id: r.doctorId, children: [] }, v.children.push(r), o.push(v)) } for (t = 0; t < i.chargeDetailListCdt.length; ++t)
                    if (r = i.chargeDetailListCdt[t], r.doctorId != null) { for (a = !1, n = 0; n < l.length; n++)
                            if (l[n].name == r.doctorName) { a = !0;
                                l[n].children.push(r); break } if (a == !1) { for (v = { name: r.doctorName, id: r.doctorId, children: [] }, e = 0; e < p.length; e++) v.children.push(p[e]);
                            l.push(v) } } for (t = 0; t < o.length; t++)
                    for (e = 0; e < p.length; e++) o[t].children.push(p[e]); for (k = [], t = 0; t < l.length; t++) { for (tt = !1, n = 0; n < o.length; n++)
                        if (l[t].id == o[n].id) { tt = !0; break } tt || k.push(l[t]) } for (t = 0; t < k.length; t++) o.push(k[t]); for (u = s(b), d = 0; d < o.length; d++) { for (w = o[d], u = {}, u = s(b), u.doctorId = w.id, u.doctorName = w.name, g = 0; g < w.children.length; g++)
                        if (h = w.children[g], h.orderType == "simple") { for (u.actualprice += h.actualPrice, nt = 0; nt < i.chargeOrderSimpleDetailList.length; nt++)
                                if (r = i.chargeOrderSimpleDetailList[nt], r) { for (it = !0, e = 0; e < i.chargeDetailList.length; e++)
                                        if (i.chargeDetailList[e].chargeOrderId == r.chargeOrderId) { it = !1; break } if (it && r.chargeOrderId == h.id)
                                        for (u.finalprice += r.totalPrice * r.discount / 100, n = 0; n < i.chargeItemCatagories.length; n++) i.chargeItemCatagories[n].itemName == r.chargeType && (u[i.chargeItemCatagories[n].index] += r.totalPrice * r.discount / 100) } } else if (h.orderType == "cdt") { for (t = 0; t < i.chargeDetailListCdt.length; t++)
                            if (f = i.chargeDetailListCdt[t], f.doctorName == u.doctorName && f && f.doctorId != null && f.chargeOrderId == h.id && (u.finalprice += f.totalPrice * 1, u.actualprice += f.totalPrice * 1, i.chargeItemCatagories))
                                for (n = 0; n < i.chargeItemCatagories.length; n++) i.chargeItemCatagories[n].id == f.chargeItemId && (u[i.chargeItemCatagories[n].index] += f.totalPrice * 1) } else if (h.orderType == "detail") { for (u.actualprice += h.actualPrice, t = 0; t < i.chargeDetailList.length; t++)
                            if (f = i.chargeDetailList[t], f.doctorId != 0 && f && f.chargeOrderId == h.id && (u.finalprice += f.finalprice * 1, i.chargeItemCatagories))
                                for (n = 0; n < i.chargeItemCatagories.length; n++) i.chargeItemCatagories[n].id == f.itemCatagoryId && (u[i.chargeItemCatagories[n].index] += f.finalprice * 1) } else h.orderType == "reimburse" && (u.actualprice += h.actualPrice);
                    u.doctorName && c.push(u) } } for (t = 0; t < c.length; t++) c[t].actualprice = c[t].actualprice, c[t].finalprice = c[t].finalprice;
            i.pageData = c;
            i.gridColumns = y },
        s = function(n) { var i = {}; for (var t in n) i[t] = typeof n[t] == "object" ? s(n[t]) : n[t]; return i },
        h = function(n) { i.pageIndex = n;
            l(i.pageIndex, i.pageSize) },
        v = function() { h(1) };
    (function() { i.pageIndex = 1;
        i.pageSize = 100;
        i.maxPageCount = 10;
        i.onPageChanged = h;
        i.search = v;
        c();
        h(1) })() }]);
managementModule.controller("PerformanceChargeDetailCtrl", ["$log", "$q", "$timeout", "$scope", "$modal", "dataDicSvc", "reportSvc", "aresDialog", "practiceSvc", "providerSvc", "gridOptionUtil", "userOptionSvc", "loginContext", "reportUtil", "permissionProvider", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y) { "use strict"; var p, w = function() { p = v.getDefaultTimeSpan(!0);
            r.timeSpan = _.clone(p) },
        b = function(n) { angular.forEach(n, function(n) { n.actualPrice = n.actualPrice || 0;
                n.planPrice = n.planPrice || 0;
                n.itemName === "退费" && (n.planPrice = n.actualPrice);
                n.fristPayDateTime && (n.fristPayDateTimeStr = moment(n.fristPayDateTime).format("YYYY-MM-DD HH:mm"));
                n.actualPrice = Ares.priceToFixed(n.actualPrice);
                n.planPrice = Ares.priceToFixed(n.planPrice) }) },
        k = function() { v.checkReportDayLimited(r.criteria.startTime, r.criteria.endTime).then(function() { e.getDoctorChargeReportData(r.criteria).success(function(n) { var t = n.dataLoad;
                    r.count = t ? t.length : 0;
                    r.showOverflowWarning = n.overflow;
                    b(t);
                    r.pageData = t }).error(function(n) { o.error("发生了一个错误", n.message) }) }) },
        d = function(n, t) { return e.getChargeOrderPatientInfo(n, t == 1 ? !0 : !1) },
        g = function() { return s.getDepartmentByOfficeId(a.officeId) },
        nt = function() { var n = t.defer(); return h.getOtherProvider().success(function(t) { t = _.filter(t, function(n) { return r.job === "doctor" ? n.job === "医生" : n.job === "护士" });
                n.resolve(t) }), n.promise },
        tt = function() { var n = t.defer(); return l.getUserOption(c.keys.doctorChargeDetailGridOption).then(function(t) { t && (r.showColumns = t.split(","));
                n.resolve(!0) }), n.promise },
        it = function(n) { var t = v.getStartEndTime(r),
                i;
            r.isShowExcelBtn = !1;
            r.job === "doctor" ? (r.criteria = { providerIdStr: r.selectCategory ? r.getProviders() : null, chargeItemIdStr: null, departmentNameStr: r.selectCategory ? null : r.getProviders(), providerType: "doctor", startTime: t.start, endTime: t.end, selectPriceType: r.selectActualPrice }, r.isShowExcelBtn = y.isAllowed("performance.doctorChargeDetailExcel")) : (r.criteria = { providerIdStr: r.selectCategory ? r.getProviders() : null, chargeItemIdStr: null, departmentNameStr: r.selectCategory ? null : r.getProviders(), providerType: "nurse", startTime: t.start, endTime: t.end, selectPriceType: r.selectActualPrice }, r.isShowExcelBtn = y.isAllowed("performance.nurseChargeDetailExcel"));
            n === "load" && (r.criteria.doctorIdStr = null, r.criteria.nurseIdStr = null, r.criteria.departmentNameStr = null);
            r.chargeItems.length > 0 && r.chargeItemNames !== "全部" && (i = _.pluck(r.chargeItems, "id"), r.criteria.chargeItemIdStr = i.join());
            k() },
        rt = function(n) { tt().then(function() { it(n) }) },
        ut = function(n) { n && l.setUserOption(c.keys.doctorChargeDetailGridOption, n) },
        ft = function() { f.chargeItemDic.load().then(function(n) { r.chargeItems = n }) },
        et = function() { var n = angular.copy(r.chargeItems),
                t = u.open({ animation: !0, backdrop: "static", template: "<item-dialog-view><\/item-dialog-view>", controller: "ItemDialogCtrl", windowClass: "followup-rule-edit-add-dialog", resolve: { host: function() { return { type: "chargeItem", list: n } } } });
            t.result.then(function(n) { var u, t, i; if (n) { for (u = n.isSaveAll ? ["全部"] : _.pluck(n.obj, "itemName"), t = "", i = 0; i < u.length; i++) { if (t.length > 10) { t += "..."; break } t += u[i] + "," } r.chargeItemNames = t === "" || t === "全部," ? "全部" : t;
                    angular.forEach(n.obj, function(n) { n.condType = "chargeItem" });
                    r.chargeItems = n.obj } }) },
        ot = function() { r.$watch("defaultSelect", function() { r.timeSpan = v.getDefaultTimeSpan(r.defaultSelect) }) };
    (function() { r.printSetting = { title: "医生收费大类", payDate: null, payType: "", printTime: null };
        r.chargeItems = [];
        r.chargeItemNames = "全部";
        r.defaultSelect = !0;
        r.selectActualPrice = 1;
        r.selectCategory = !0;
        r.showOverflowWarning = !1;
        r.openDialog = et;
        r.search = rt;
        r.jobName = r.job === "doctor" ? "医生" : "护士";
        r.printSetting = { title: "", payDate: null, payType: "", printTime: null };
        r.updateColumnsOption = ut;
        r.getChargeOrderPatientInfo = d;
        r.getOfficeDepartments = g;
        r.getOfficeProviders = nt;
        ft();
        w();
        ot() })() }]);
managementModule.controller("PerformanceDoctorApptCtrl", ["$log", "$filter", "$scope", "$modal", "aresDialog", "reportSvc", "reportUtil", function(n, t, i, r, u, f, e) { "use strict"; var o, h = function() { o = e.getDefaultTimeSpan(!0);
            i.timeSpan = _.clone(o) },
        c = function(n) { return n && n.length > 0 && (i.columns = [{ field: "doctorName", menu: !1, title: "医生姓名", width: "100px", footerTemplate: "总计" }, { field: "department", menu: !1, title: "科室", width: "100px" }, { field: "totalVisitCnt", title: "总诊次数", width: "100px", aggregates: ["sum"], footerTemplate: "#=sum#" }, { field: "totalAmount", title: "总金额", width: "100px", aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }], i.aggregates = [{ field: "totalVisitCnt", aggregate: "sum" }, { field: "totalAmount", aggregate: "sum" }], n[0].checkIns.forEach(function(n, t) { i.columns.push({ field: "vGroupCnt" + t, title: n.name + "次数", width: "100px", aggregates: ["sum"], footerTemplate: "#=sum#" }, { field: "vGroupAmount" + t, title: n.name + "金额", width: "100px", aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" });
                i.aggregates.push({ field: "vGroupCnt" + t, aggregate: "sum" }, { field: "vGroupAmount" + t, aggregate: "sum" }) }), n.forEach(function(n) { n.checkIns.forEach(function(t, i) { Object.defineProperty(n, "vGroupCnt" + i, { value: t.count, enumerable: !0 });
                    Object.defineProperty(n, "vGroupAmount" + i, { value: t.amount, enumerable: !0 }) }) })), n },
        s = function(n) { var t = e.getStartEndTime(i),
                r = n === "load" ? "-1" : i.getDoctorIds();
            e.checkReportDayLimited(t.start, t.end).then(function() { f.getDoctorApptCountReport(t.start, t.end, r, i.selectActualPrice).success(function(n) { i.pageData = c(n) }) }) },
        l = function() { s() };
    (function() { i.defaultSelect = !0;
        i.selectActualPrice = 1;
        i.columns = [];
        i.aggregates = [];
        i.pageData = [];
        i.search = l;
        h();
        s("load");
        i.$watch("defaultSelect", function() { i.timeSpan = e.getDefaultTimeSpan(i.defaultSelect) }) })() }]);
managementModule.controller("PerformanceNetworkConsultCtrl", ["$log", "$scope", "$q", "$modal", "reportSvc", "practiceSvc", "loginContext", "patientUtil", "aresNotification", function(n, t, i, r, u, f, e, o, s) { "use strict"; var h = function() { var i = t.timeSpan.startDate ? moment(t.timeSpan.startDate).format("YYYY-MM-DD") : t.timeSpan.startDate,
                r = t.timeSpan.endDate ? moment(t.timeSpan.endDate).add(1, "day").format("YYYY-MM-DD") : t.timeSpan.endDate,
                n; if (!t.timeSpan.startDate || moment(t.timeSpan.startDate).add(12, "month") < moment(t.timeSpan.endDate)) { s.error("一次最多查询一年数据"); return } n = o.getPatientPermissionLevel();
            u.getNetworkConsultPerformanceList(i, r, t.searchText, n).success(function(n) { for (var i = 0; i < n.length; i++) n[i].startDateStr = moment(n[i].startDate).format("YYYY年MM月DD日"), n[i].endDateStr = moment(n[i].endDate).format("YYYY年MM月DD日");
                t.pageData = n }) },
        c = function() { return [{ field: "sequenceNum", title: "序号", width: "80px" }, { field: "patientName", title: "患者姓名", width: "140px" }, { field: "privateId", title: "病历号", width: "140px" }, ] },
        l = function(n) { var i = c(); return n == 0 || n == 1 ? (i.push({ field: "createTimeStr", title: "患者创建时间", width: "140px" }), i.push({ field: "patientNotes", title: "患者备注", width: "140px" })) : n == 2 ? (i.push({ field: "createTimeStr", title: "预约创建时间", width: "140px" }), i.push({ field: "appointTimeStr", title: "预约时间", width: "140px" }), i.push({ field: "officeName", title: "预约门店", width: "140px" }), i.push({ field: "doctorName", title: "预约医生", width: "140px" }), i.push({ field: "transactionItems", title: "预约项目", width: "140px" }), i.push({ field: "notes", title: "备注", width: "140px" })) : n == 5 && (i = [{ field: "sequenceNum", title: "序号", width: "80px", footerTemplate: "总计" }, { field: "patientName", title: "患者姓名", width: "140px" }, { field: "privateId", title: "病历号", width: "140px" }], i.push({ field: "createTimeStr", title: "收费时间", width: "140px" }), i.push({ field: "officeName", title: "就诊门店", width: "140px" }), i.push({ field: "appointTimeStr", title: "就诊时间", width: "140px" }), i.push({ field: "itemSuperTypes", title: "收费大类", width: "140px" }), i.push({ field: "itemTypes", title: "收费小类", width: "140px" }), i.push({ field: "itemNames", title: "收费项目", width: "140px" }), i.push({ field: "planPrice", title: "应收", width: "140px", aggregates: ["sum"], format: "{0:n}", footerTemplate: "#=kendo.toString(sum,'c2')#" }), i.push({ field: "actualPrice", title: "实收", width: "140px", aggregates: ["sum"], format: "{0:n}", footerTemplate: "#=kendo.toString(sum,'c2')#" }), i.push({ field: "notes", title: "备注", width: "140px" }), t.aggregate = [{ field: "planPrice", aggregate: "sum" }, { field: "actualPrice", aggregate: "sum" }]), i },
        a = function(n) { for (var t = 0; t < n.length; t++) n[t].createTimeStr = moment(n[t].createTime).format("YYYY-MM-DD HH:mm:ss"), n[t].appointTimeStr = moment(n[t].appointTime).format("YYYY-MM-DD HH:mm:ss") },
        v = function(n, i, u) { var f = r.open({ animation: !0, backdrop: "static", template: "<performance-network-consult-detail-dialog-view><\/performance-network-consult-detail-dialog-view>", controller: "PerformanceNetworkConsultDetailDialogCtrl", windowClass: "charge-detail-dialog", resolve: { host: function() { return { pageData: n, column: i, showType: u, aggregate: t.aggregate } } } }) },
        y = function(n, i) { var r = t.timeSpan.startDate ? moment(t.timeSpan.startDate).format("YYYY-MM-DD") : t.timeSpan.startDate,
                f = t.timeSpan.endDate ? moment(t.timeSpan.endDate).add(1, "day").format("YYYY-MM-DD") : t.timeSpan.endDate;
            u.getNetworkConsultPerformanceDetailList(r, f, n, i).success(function(n) { a(n); var t = l(i);
                v(n, t, i) }) };
    (function() { t.search = h;
        t.showDetail = y })() }]);
managementModule.controller("ScheduleDoctorCtrl", ["$log", "$filter", "$scope", "$modal", "appNav", function() { "use strict";
    (function() {})() }]);
managementModule.controller("ScheduleRulesettingDialogCtrl", ["$log", "$filter", "$scope", "$modalInstance", "practiceSvc", "aresDialog", "host", function(n, t, i, r, u, f, e) { "use strict";
    i.cancel = function() { r.dismiss("cancel") };
    i.ok = function() { var n, t, e; if (i.currentRuleDetail) { if (i.existList)
                    for (n = 0; n < i.existList.length; ++n)
                        if (i.existList[n].name == i.currentRuleDetail.name) { f.warn("错误", "班次名称已被使用，请改名"); return } if (i.currentRuleDetail.ST = moment("2015-01-01 " + i.currentRuleDetail.startTime, "YYYY-MM-DD HH:mm"), t = i.currentRuleDetail.ST.isValid(), i.currentRuleDetail.ET = moment("2015-01-01 " + i.currentRuleDetail.endTime, "YYYY-MM-DD HH:mm"), e = i.currentRuleDetail.ET.isValid(), !e || !t) { f.warn("错误", "班次时间格式不正确"); return } if (i.currentRuleDetail.ST >= i.currentRuleDetail.ET) { f.info("信息", "上班时间必须早于下班时间！"); return } i.currentRuleDetail.id > 0 ? u.updateScheduleRuleDetail(i.currentRuleDetail).success(function() { f.info("信息", "保存成功！");
                    r.close(i.currentRuleDetail) }) : u.createScheduleRuleDetail(i.currentRuleDetail).success(function() { f.info("信息", "保存成功！");
                    r.close(i.currentRuleDetail) }) } },
        function() { i.existList = e.existList;
            e.id > 0 ? u.getScheduleRuleDetail(e.id).success(function(n) { n.startTime = moment(n.startTime).format("HH:mm");
                n.endTime = moment(n.endTime).format("HH:mm");
                i.currentRuleDetail = n; var t = $("#palette").data("kendoColorPicker");
                t.value(i.currentRuleDetail.scheduleColor) }) : i.currentRuleDetail = { id: 0, name: "", weekDayType: "AllWeekDays", startTime: "08:00", endTime: "18:00", scheduleColor: "#FFD9D9", status: "SHIFT" } }() }]);
managementModule.controller("ScheduleRulesettingCtrl", ["$log", "$filter", "$scope", "$modal", "appNav", function() { "use strict";
    (function() {})() }]);
managementModule.controller("ScheduleTenantCtrl", ["$log", "$filter", "$scope", "$modal", "appNav", function() { "use strict";
    (function() {})() }]);
managementModule.controller("ComplaintListCtrl", ["$log", "$scope", "$q", "loginContext", "complaintSvc", "eventAggregator", "multiOfficeDataDic", function(n, t, i, r, u, f, e) { "use strict"; var o = function() { var n = i.defer(),
                u = r.officeId; return e.loadDic(u, "currentOfficeWorkProviderDic").then(function(i) { t.providers = i;
                n.resolve(!0) }), n.promise },
        s = function(n) { var o = i.defer(),
                u = t.timeStatus,
                f = t.providerType,
                e = t.providerId,
                r = { pageSize: t.pageSize, pageIndex: n ? 1 : t.pageIndex, complaintStates: t.complaintStates, category: t.category, severitys: t.severity, satisfaction: t.satisfaction }; return u == 1 ? (r.satrtRecordTime = t.startTime, r.endRecordTime = t.endTime) : u == 2 ? (r.startProcessTime = t.startTime, r.endProcessTime = t.endTime) : u == 3 && (r.startFeedbackTime = t.startTime, r.endFeedbackTime = t.endTime), f == 1 ? r.recordProviderId = e : f == 2 ? r.processProviderId = e : f == 3 && (r.feedbackProviderId = e), o.resolve(r), o.promise },
        h = function(n) { var r = i.defer(); return s(n).then(function(n) { u.searchComplaint(n).success(function(n) { t.pageData = n;
                    r.resolve(t.pageData) }) }), r.promise },
        c = function() { f.subscribe(t, f.events.ComplaintActionChanged, function() { t.search() }) };
    (function() { t.complaintData = {};
        t.pageSize = 20;
        t.pageIndex = 1;
        t.refreshListData = h;
        t.initProviders = o;
        c() })() }]);
managementModule.controller("ConsultIntentionEditCtrl", ["$log", "$scope", "$modalInstance", "aresDialog", "aresNotification", "systemitemSvc", "dataDicSvc", "host", function(n, t, i, r, u, f, e, o) { "use strict";
    t.cancel = function() { i.dismiss("cancel") };
    t.saveSystemItem = function() { t.action == "add" ? f.createSystemItem(t.currentSystemItem).success(function(n) { u.success("保存成功！");
            e.systemItemDic.refresh();
            i.close(n) }).error(function(n) { n.name === "SystemItemNameNotUniqueException" && r.warn("警告", "已经有其他项目使用此名称，请更换新名称！") }) : f.updateSystemItem(t.currentSystemItem).success(function(n) { u.success("保存成功！");
            e.systemItemDic.refresh();
            i.close(n) }).error(function(n) { n.name === "SystemItemNameNotUniqueException" && r.warn("警告", "已经有其他项目使用此名称，请更换新名称！") }) }; var s = function() { t.currentSystemItem && t.action != "add" || (t.currentSystemItem = { ItemName: "", ItemType: "成交意愿" }) };
    (function() { t.currentSystemItem = o.currentSystemItem;
        t.action = o.action;
        s() })() }]);
managementModule.controller("consultIntentionCtrl", ["$log", "$q", "$scope", "$timeout", "$modal", "$filter", "dataDicSvc", "aresDialog", "systemitemSvc", "aresNotification", function(n, t, i, r, u, f, e, o, s, h) { "use strict"; var c = function() { e.systemItemDic.loadActive({ itemType: "成交意愿" }).then(function(n) { i.intentions = n }) },
        l = function(n) { var t = u.open({ animation: !0, backdrop: "static", template: "<consult-intention-edit-view><\/consult-intention-edit-view>", controller: "ConsultIntentionEditCtrl", resolve: { host: function() { return { currentSystemItem: i.selectedItem, action: n } } } });
            t.result.then(function(n) { n && c() }) },
        a = function() { if (i.selectedItem) { var n = i.selectedItem;
                o.confirm("删除成交意愿", "您确认要删除成交意愿【" + n.itemName + "】吗？").then(function() { s.deleteSystemItem(n.id).success(function() { e.systemItemDic.refresh();
                        c();
                        h.success("删除成功！") }) }) } };
    (function() { i.edit = l;
        i.destroy = a;
        c() })() }]);
managementModule.controller("consultListCtrl", ["$log", "$q", "$scope", "$timeout", "$filter", "appointmentConsultSvc", "dataDicSvc", "aresNotification", "permissionProvider", "loginContext", function(n, t, i, r, u, f, e, o, s, h) { "use strict"; var v = function() { var n = Ares.today(),
                t = moment(Ares.today()).startOf("month").toDate(),
                r = { startDate: t, endDate: n };
            i.timeSpan = _.clone(r) },
        y = function(n) { n == "previous" ? (i.timeSpan.startDate = moment(i.timeSpan.startDate).add(-1, i.selectDate).startOf(i.selectDate).toDate(), i.timeSpan.endDate = moment(i.timeSpan.endDate).add(-1, i.selectDate).endOf(i.selectDate).toDate()) : n == "next" && (i.timeSpan.startDate = moment(i.timeSpan.startDate).add(1, i.selectDate).startOf(i.selectDate).toDate(), i.timeSpan.endDate = moment(i.timeSpan.endDate).add(1, i.selectDate).endOf(i.selectDate).toDate());
            c() },
        l = function(n) { switch (n) {
                case "all":
                    i.timeSpan.startDate = null;
                    i.timeSpan.endDate = null;
                    i.selectDate = "all"; break;
                case "day":
                    i.timeSpan.startDate = moment(Ares.today()).toDate();
                    i.timeSpan.endDate = moment(Ares.today()).toDate();
                    i.selectDate = "day"; break;
                case "week":
                    i.timeSpan.startDate = moment(Ares.today()).startOf("week").toDate();
                    i.timeSpan.endDate = moment(Ares.today()).endOf("week").toDate();
                    i.selectDate = "week"; break;
                case "month":
                    i.timeSpan.startDate = moment(Ares.today()).startOf("month").toDate();
                    i.timeSpan.endDate = moment(Ares.today()).endOf("month").toDate();
                    i.selectDate = "month"; break;
                case "custom":
                    i.timeSpan.endDate || v();
                    i.selectDate = "custom" } c() },
        p = function() { i.searchCriteria = { startDate: null, endDate: null, consultantId: -1, intention: "", checkInType: null, privateTag: i.privateTag };
            i.isAlloweViewAllConsults || (i.searchCriteria.consultantId = h.providerId);
            i.page = { index: 1, size: 15 };
            i.selectDate = "day";
            i.timeSpan = {};
            l("day") },
        a = function() { if (i.searchCriteria.startDate = i.timeSpan.startDate ? moment(i.timeSpan.startDate).format("YYYY-MM-DD") : i.timeSpan.startDate, i.searchCriteria.endDate = i.timeSpan.endDate ? moment(i.timeSpan.endDate).add(1, "day").format("YYYY-MM-DD") : i.timeSpan.endDate, moment(i.searchCriteria.startDate).add(1, "years") < moment(i.searchCriteria.endDate)) return o.error("查询时间跨度不能超过一年"), !1;
            i.searchCriteria.pageIndex = i.page.index;
            i.searchCriteria.pageSize = i.page.size;
            i.isAlloweViewAllConsults || (i.searchCriteria.consultantId = h.providerId);
            i.searchCriteria.intention = i.searchCriteria.intention == "全部" ? "" : i.searchCriteria.intention;
            i.searchCriteria.consultItem = i.searchCriteria.consultItem == "全部" ? "" : i.searchCriteria.consultItem;
            i.searchCriteria.privateTag = i.privateTag },
        c = function() { a();
            f.searchAppointmentConsultList(i.searchCriteria).then(function(n) { for (var t, r = n.data, u = 0; u < r.items.length; u++) t = r.items[u], t.tagStr && (t.tagStr = t.tagStr.substring(0, t.tagStr.length - 1), t.tagStr = t.tagStr.substring(1)), t.isHistoryDeal = t.isHistoryDeal ? "是" : "否";
                i.apptConsultList = r.items;
                i.page.count = r.pageCount;
                i.page.size = r.pageSize;
                i.page.index = r.pageIndex;
                i.page.totalCount = r.totalCount;
                i.initView() }) },
        w = function() { a(); var n = { criteria: i.searchCriteria, columns: [{ field: "name", title: "姓名" }, { field: "tagStr", title: "自定义标签" }, { field: "gender", title: "性別" }, { field: "age", title: "年龄" }, { field: "mobile", title: "手机号" }, { field: "phoneNumber", title: "电话" }, { field: "location", title: "所在地区" }, { field: "startTime", title: "就诊日期" }, { field: "sourceTypeStr", title: "患者来源" }, { field: "consultantName", title: "咨询师" }, { field: "consultItem", title: "咨询项目" }, { field: "consultContent", title: "咨询内容" }, { field: "intention", title: "成交意愿" }, { field: "state", title: "是否成交" }, { field: "actualAmount", title: "实际实收" }, { field: "membershipPrice", title: "充值金额" }, { field: "reason", title: "备注" }, { field: "isHistoryDeal", title: "历史成交" }, { field: "checkInType", title: "就诊类型" }] };
            f.exportAppointmentConsultList(n) };
    (function() { i.privateTag = "";
        i.switchDate = l;
        i.updateDate = y;
        i.searchConsultPagedList = c;
        i.initSearchCriteriaData = p;
        i.exportConsultsList = w })() }]);
managementModule.controller("ConsultNetworkListCtrl", ["$log", "$scope", "$q", "$modal", "$filter", "$timeout", "dashboardSvc", "appointmentConsultSvc", "loginContext", "patientUtil", "apptUtil", "appointmentSvc", "patientSvc", "eventAggregator", "aresNotification", "sessionCache", "officeOptionSvc", "aresDialog", "speechCallSvc", "aresSlidePanel", "onlineConsultSvc", "userOptionSvc", "gridOptionUtil", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y, p, w, b, k, d, g, nt, tt) { "use strict"; var it, ut = function() { var n = Ares.today(),
                i = moment(Ares.today()).startOf("month").toDate();
            it = { startDate: i, endDate: n };
            t.timeSpan = _.clone(it) },
        rt = function() { var n = i.defer(),
                u = _.some(t.showColumns, function(n) { return n ? n.startsWith("next") || n === "patientStatus" : !1 }),
                r = { startDate: t.timeSpan && t.timeSpan.startDate ? moment(t.timeSpan.startDate).format("YYYY-MM-DD") : null, endDate: t.timeSpan && t.timeSpan.endDate ? moment(t.timeSpan.endDate).format("YYYY-MM-DD") : null, officeId: t.officeId, pageIndex: t.pageIndex, pageSize: t.pageSize, selectCode: t.selectCode, userId: t.userId, intentions: t.getIntentions(), consultItem: t.consultItem, content: t.content, isNeedAppt: u, hasNoneAppt: t.apptStatus.none, hasApptNoCheckIn: t.apptStatus.noCheckin, hasApptCheckIn: t.apptStatus.checkin }; return r.level = h.getPatientPermissionLevel(), n.resolve(r), n.promise },
        ft = function() { var n = i.defer(); return rt().then(function(i) { e.getGroupOnlineConsult(i).success(function(i) { et(i.items);
                    t.pageData = i;
                    h.formatPatientHeadInfo(t.pageData.items).then(function(i) { t.pageData.items = i;
                        n.resolve(t.pageData) }) }) }), n.promise },
        et = function(n) { for (var t, i = 0; i < n.length; i++) t = n[i], t.index = i + 1, t.id = t.onlineConsultId, t.sexStr = u("toSexString")(t.sex), t.ageStr = u("toAgeYearString")(t.birth), t.consultTimeStr = moment(t.consultTime).format("YYYY-MM-DD HH:mm"), t.nextApptTimeStr = t.nextApptTime ? moment(t.nextApptTime).format("YYYY-MM-DD HH:mm") : "", t.nextCheckInTimeStr = t.nextCheckInTime ? moment(t.nextCheckInTime).format("YYYY-MM-DD HH:mm") : "" },
        ot = function() { var n = d.open("<online-consult-detail-edit-view><\/online-consult-detail-edit-view>", "OnlineConsultDetailEditCtrl", { host: function() { return { title: "新建咨询" } } }, t);
            n.result.then(function() { v.publish(v.events.OnlineConsultCreated, null, "GroupDashboardFrontCtrl");
                t.refreshGrid() }) },
        st = function(n) { var i = d.open("<online-consult-detail-edit-view><\/online-consult-detail-edit-view>", "OnlineConsultDetailEditCtrl", { host: function() { return { title: "编辑咨询", consultId: n.onlineConsultId, patientId: n.patientId } } }, t);
            i.result.then(function() { t.refreshGrid() }) },
        ht = function(n) { b.confirm("信息", "确定要删除吗！").then(function() { g.deleteOnlineConsult(n).success(function() { y.success("删除成功！");
                    t.refreshGrid();
                    v.publish(v.events.OnlineConsultCreated, null, "GroupDashboardFrontCtrl") }) }) },
        ct = function() { var n = t.pageData ? t.pageData.totalCount : 0;
            t.$parent && t.$parent.refreshDashboardBlockHint && t.$parent.refreshDashboardBlockHint(n) },
        lt = function() { var n = i.defer(); return nt.getUserOption(tt.keys.groupDashboardOnlineConsultGridOption).then(function(i) { t.showColumns = i != null ? _.without(i.split(",")) : ["^"];
                n.resolve(!0) }), n.promise };
    (function() { t.initDefaultTimeSpan = ut;
        t.updateCount = ct;
        t.refreshOnlineConsult = ft;
        t.initSearchCriteria = rt;
        t.createConsult = ot;
        t.deleteOnlineConsult = ht;
        t.editConsult = st;
        t.userId = -1;
        t.loadColumnsOption = lt })() }]);
managementModule.controller("sceneConsultListCtrl", ["$log", "$scope", "$modal", "$filter", "appNav", "constants", "enums", "patientSvc", "formatUtil", "shortMessageUtil", "aresDialog", "commonTaskSvc", "sessionCache", "officeOptionSvc", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v) { "use strict"; var w, p = a.getCache(a.keys.SceneConsultListSearchCriteria);
    t.sceneConsultListCache = p; var y = function(n) { var i = Ares.today(),
                r = moment(i).add(-1, "week").toDate();
            w = { startDate: r, endDate: i };
            t.timeSpan = _.clone(w);
            n && Ares.sensors.trackDropDownEvent("sceneConsultList", "日期") },
        b = function() { d() },
        k = function() { var n, i, r = t.range || $("#daysBeforeTodayInput").val();
            r == "自定义" ? (n = t.timeSpan.startDate, i = moment(t.timeSpan.endDate).add(1, "d")) : r == "week" ? (n = moment(Ares.today()).startOf("week"), i = moment(Ares.today()).add(1, "d")) : r == "month" ? (n = moment(Ares.today()).startOf("month"), i = moment(Ares.today()).add(1, "d")) : (n = moment(Ares.today()).add(-r, "d"), i = moment(Ares.today()).add(1, "d")); var u = t.consultantId > 0 ? t.consultantId : -1,
                f = t.status >= 0 ? t.status : -1,
                e = t.consultItem == "全部" ? "" : t.consultItem; return t.isSearching = !0, t.criteria = { consultanttask_daysBeforeTodayInput: r, consultanttask_startTime: n, consultanttask_endTime: moment(i).add(-1, "d"), consultanttask_consultantId: u, consultanttask_status: f, consultanttask_cosnsultItem: e, consultanttask_checkInType: t.checkInType, consultanttask_selectCode: t.selectCode, consultanttask_pageIndex: t.pageIndex, consultanttask_pageSize: t.pageSize }, p.saveObject(t.criteria), { startDate: moment(n).format("YYYY-MM-DD"), endDate: moment(i).format("YYYY-MM-DD"), consultantId: u, status: f, consultItem: e, checkInType: t.checkInType, selectCode: t.selectCode, pageIndex: t.pageIndex, pageSize: t.pageSize } },
        d = function() { var n = k();
            l.getConsultantRecordTasks(n).success(function(n) { for (var i = 0; i < n.items.length; i++) n.items[i].startTimeSource = n.items[i].startTime, n.items[i].startTime = r("toDateTimeString")(n.items[i].startTime);
                t.searchResult = n }).error(function() { t.isSearching = !1 }) },
        g = function() { v.isStrongStrictAllowed().then(function(n) { t.isStrongStrict = n }) };
    (function() { g();
        t.range = "0";
        t.isStrongStrict = !1;
        t.initCriteria = k;
        t.initDefaultTimeSpan = y; var n = p.loadObject();
        t.consultantId = n.consultanttask_consultantId ? n.consultanttask_consultantId : -1;
        t.consultItem = n.consultanttask_consultItem ? n.consultanttask_consultItem : "全部";
        t.checkInType = n.consultanttask_checkInType ? n.consultanttask_checkInType : null;
        t.status = n.consultanttask_status ? n.consultanttask_status : -1;
        n.consultanttask_daysBeforeTodayInput ? (t.range = n.consultanttask_daysBeforeTodayInput, n.consultanttask_daysBeforeTodayInput == "自定义" ? n.consultanttask_startTime ? (y(), t.timeSpan.startDate = moment(n.consultanttask_startTime).format("YYYY-MM-DD"), t.timeSpan.endDate = moment(n.consultanttask_endTime).format("YYYY-MM-DD")) : y() : y()) : y();
        t.search = b;
        b() })() }]);
managementModule.controller("CustomerClueManagementCtrl", ["$log", "$scope", "$q", "loginContext", "customerClueSvc", "eventAggregator", "multiOfficeDataDic", "practiceSvc", "dataDicSvc", function(n, t, i, r, u, f, e, o, s) { "use strict"; var l = function() { var n = i.defer(),
                u = r.officeId; return e.loadDic(u, "currentOfficeWorkProviderDic").then(function(i) { t.providers = i;
                n.resolve(!0) }), n.promise },
        v = function() { var n = i.defer(),
                u = r.officeId; return e.loadDic(u, "webPhoneConsultantDic").then(function(i) { t.AssigeeProviders = _.filter(i, function(n) { return n.isInactive == !1 && n.show == !0 });
                n.resolve(!0) }), n.promise },
        y = function() { var n = i.defer(); return s.systemItemDic.loadActive({ itemType: "跟进类型" }).then(function(i) { i.splice(0, 0, { itemName: "全部" });
                t.systemSettingitems = i;
                n.resolve(!0) }), n.promise },
        p = function() { var u = i.defer(),
                n = t.criteria,
                f = n.startRecordCreateTime,
                v = n.endRecordCreateTime,
                e = n.startComplaintTime,
                r = n.endComplaintTime,
                o = n.appointmentStartTime,
                s = n.appointmentEndTime,
                l = n.startAssignTime,
                a = n.endAssignTime; return f && (n.startRecordCreateTime = h(f)), r && (n.endRecordCreateTime = h(v)), e && (n.startComplaintTime = h(e)), r && (n.endComplaintTime = h(r)), o && (n.appointmentStartTime = h(o)), s && (n.appointmentEndTime = h(s)), l && (n.startAssignTime = h(l)), a && (n.endAssignTime = h(a)), n.firstFollow = c(n.firstFollow), n.nextFollow = c(n.nextFollow), n.lastFollow = c(n.lastFollow), u.resolve(n), u.promise },
        w = function(n) { var r = i.defer(); return p(n).then(function(n) { u.searchCustomerClue(n).success(function(n) { l().then(function() { angular.forEach(n.items, function(n) { var i = _.find(t.providers, function(t) { return n.recordCreatedUser == t.userID });
                            n.recordCreatedName = i ? i.name : "公司管理员" });
                        t.pageData = n;
                        r.resolve(t.pageData) }) }) }), r.promise },
        b = function() { var n = i.defer(); return u.closeCustomerClue().then(function() { n.resolve(!0) }), n.promise },
        h = function(n, t) { var n = moment(n).format("YYYY-MM-DD"); return t && (n = moment(n).add(1, "day").format("YYYY-MM-DD")), n },
        c = function(n) { return n == "全部" && (n = null), n },
        a = function() { t.criteria = { pageSize: 20, pageIndex: 1, startRecordCreateTime: "", startComplaintTime: "", appointmentStartTime: "", startAssignTime: "" } };
    (function() { t.refreshListData = w;
        t.initProviders = l;
        t.initItemType = y;
        t.initCriteria = a;
        t.initAssigeeProviders = v;
        t.closeCustomerClue = b;
        a() })() }]);
managementModule.controller("CustomerClueTrackCtrl", ["$log", "$scope", "$q", "loginContext", "customerClueSvc", "eventAggregator", "practiceSvc", "patientSvc", "patientUtil", "aresNotification", function(n, t, i, r, u, f, e, o, s, h) { "use strict"; var y = function() { var n = i.defer(); return e.getItemTypes(t.itemType).success(function(i) { i.splice(0, 0, { itemName: "全部" });
                t.systemSettingitems = i;
                n.resolve(!0) }), n.promise },
        p = function(n, t) { s.createCrossOfficeFollowUpAppt(t).then(function(t) { a(n, t.id);
                h.success("预约成功") }) },
        w = function(n, t) { o.getPatientConsultantId(t).then(function(i) { s.createFollowUpApptByPatientId(t, null, null, i.data).then(function(t) { a(n, t.id);
                    h.success("预约成功") }) }) },
        a = function(n, t) { var i = { id: n, appointmentId: t };
            u.updateAppointment(i).success(function() {}) },
        b = function(n) { var r = i.defer(); return o.getPatient(n).success(function(n) { t.patient = n;
                r.resolve(!0) }), r.promise },
        k = function() { var e = i.defer(),
                n = t.criteria,
                r = n.startRecordCreateTime,
                u = n.startComplaintTime,
                f = n.appointmentStartTime; return r ? (n.startRecordCreateTime = c(r), n.endRecordCreateTime = c(r, 1)) : n.endRecordCreateTime = null, u ? (n.startComplaintTime = c(u), n.endComplaintTime = c(u, 1)) : n.endComplaintTime = null, f ? (n.appointmentStartTime = c(f), n.appointmentEndTime = c(f, 1)) : n.appointmentEndTime = null, n.firstFollow = l(n.firstFollow), n.nextFollow = l(n.nextFollow), n.lastFollow = l(n.lastFollow), e.resolve(n), e.promise },
        d = function(n) { var r = i.defer(); return k(n).then(function(n) { u.searchCustomerClue(n).success(function(n) { t.pageData = n;
                    r.resolve(t.pageData) }) }), r.promise },
        c = function(n, t) { var n = moment(n).format("YYYY-MM-DD"); return t && (n = moment(n).add(1, "day").format("YYYY-MM-DD")), n },
        l = function(n) { return n == "全部" && (n = null), n },
        v = function() { t.criteria = { pageSize: 20, pageIndex: 1, startRecordCreateTime: "", startComplaintTime: "", appointmentStartTime: "", isAssigned: !0 } };
    (function() { t.refreshListData = d;
        t.initItemType = y;
        t.initCriteria = v;
        t.createCrossOfficeAppt = p;
        t.createFollowUpApptByPatientId = w;
        t.getPatient = b;
        v() })() }]);
managementModule.controller("ExpenditureEditCtrl", ["$log", "$scope", "$modalInstance", "$modal", "host", "expendSvc", function(n, t, i, r, u, f) { "use strict"; var o = function() { t.expend = { expendTime: moment().toDate() } },
        e = function() { f.getExpenditure(u.id).success(function(n) { n.expendTime = moment(n.expendTime).toDate();
                t.expend = n }) },
        s = function() { i.dismiss("cancel") },
        h = function() { if (Ares.ensureNotDuplicated("SaveExpend")) { if (!t.expend.operatorId) { t.showErrorNotification("请选择经办人！"); return } if (!t.expend.expendType || t.expend.expendType == "请选择") { t.showErrorNotification("请选择支出类别！"); return } if (!t.expend.payType || t.expend.payType == "请选择") { t.showErrorNotification("请选择支付方式！"); return } if (!t.expend.amount) { t.showErrorNotification("请输入金额！"); return } t.expend.expendTime = moment(t.expend.expendTime).format("YYYY-MM-DD HH:mm");
                u.type == "add" ? f.addExpenditure(t.expend).success(function(n) { n && i.close() }) : f.editExpenditure(t.expend).success(function(n) { n && i.close() }) } },
        c = function(n) { var i = r.open({ animation: !0, backdrop: "static", template: "<system-setting-item-edit><\/system-setting-item-edit>", controller: "SystemSettingItemEditCtrl", resolve: { host: function() { return { itemType: n } }, boxTitle: function() { return "" } } });
            i.result.then(function() { n == "支出类别" ? t.initExpendType() : t.initExpendPayType() }) };
    (function() { t.cancel = s;
        t.save = h;
        t.editSetting = c;
        u.type == "edit" ? (t.title = "编辑支出记录", e()) : u.type == "add" ? (t.title = "新增支出记录", o()) : (t.title = "查看支出记录", e(), t.isBrowsed = !0) })() }]);
managementModule.controller("ExpenditureListCtrl", ["$log", "$scope", "$modal", "formatUtil", "membershipSvc", "aresDialog", "expendSvc", function(n, t, i, r, u, f, e) { "use strict"; var h, c = function() { var n = Ares.today(),
                i = moment(Ares.today()).startOf("month").toDate();
            h = { startDate: i, endDate: n };
            t.timeSpan = _.clone(h) },
        o = function() { t.criteria.startTime = t.timeSpan.startDate ? moment(t.timeSpan.startDate).format("YYYY-MM-DD") : t.timeSpan.startDate;
            t.criteria.endTime = t.timeSpan.endDate ? moment(t.timeSpan.endDate).add(1, "day").format("YYYY-MM-DD") : t.timeSpan.endDate;
            t.criteria.pageIndex = t.pageIndex;
            t.criteria.pageSize = t.pageSize;
            e.getPageExpenditures(t.criteria).success(function(n) { var i, r; for (t.pageExpenditures = n.expenditures, i = 0; i < t.pageExpenditures.items.length; i++) r = t.pageExpenditures.items[i], r.amount = s(r.amount.toFixed(2));
                n.subtotal = s(n.subtotal.toFixed(2));
                n.totalAmount = s(n.totalAmount.toFixed(2));
                t.pageData = n }) },
        s = function(n) { n = n + ""; for (var t = /(-?\d+)(\d{3})/; t.test(n);) n = n.replace(t, "$1,$2"); return n },
        l = function() { o() },
        a = function() { t.criteria = { startTime: null, endTime: null, expendType: "", payType: "", expendDetail: "", operatorId: 0, principalId: 0, pageSize: 15, pageIndex: 1 };
            t.selectDate = "all";
            t.timeSpan = {};
            o() },
        v = function(n) { n == "previous" ? (t.timeSpan.startDate = moment(t.timeSpan.startDate).add(-1, t.selectDate).startOf(t.selectDate).toDate(), t.timeSpan.endDate = moment(t.timeSpan.endDate).add(-1, t.selectDate).endOf(t.selectDate).toDate()) : n == "next" && (t.timeSpan.startDate = moment(t.timeSpan.startDate).add(1, t.selectDate).startOf(t.selectDate).toDate(), t.timeSpan.endDate = moment(t.timeSpan.endDate).add(1, t.selectDate).endOf(t.selectDate).toDate());
            o() },
        y = function(n) { switch (n) {
                case "all":
                    t.timeSpan.startDate = null;
                    t.timeSpan.endDate = null;
                    t.selectDate = "all"; break;
                case "day":
                    t.timeSpan.startDate = moment(Ares.today()).toDate();
                    t.timeSpan.endDate = moment(Ares.today()).toDate();
                    t.selectDate = "day"; break;
                case "week":
                    t.timeSpan.startDate = moment(Ares.today()).startOf("week").toDate();
                    t.timeSpan.endDate = moment(Ares.today()).endOf("week").toDate();
                    t.selectDate = "week"; break;
                case "month":
                    t.timeSpan.startDate = moment(Ares.today()).startOf("month").toDate();
                    t.timeSpan.endDate = moment(Ares.today()).endOf("month").toDate();
                    t.selectDate = "month"; break;
                case "custom":
                    t.timeSpan.endDate || c();
                    t.selectDate = "custom" } o() },
        p = function() { var n = i.open({ animation: !0, backdrop: "static", template: "<expenditure-edit-view><\/expenditure-edit-view>", controller: "ExpenditureEditCtrl", windowClass: "expenditure-edit-dialog", resolve: { host: function() { return { type: "add" } } } });
            n.result.then(function() { t.showNotification("添加成功！");
                o() }) },
        w = function(n) { var r = i.open({ animation: !0, backdrop: "static", template: "<expenditure-edit-view><\/expenditure-edit-view>", controller: "ExpenditureEditCtrl", windowClass: "expenditure-edit-dialog", resolve: { host: function() { return { type: "edit", id: n } } } });
            r.result.then(function() { t.showNotification("修改成功！");
                o() }) },
        b = function(n) { f.confirm("提示", "您确认要删除这条记录吗？").then(function() { e.deleteExpenditure(n).success(function() { t.showNotification("删除成功！");
                    o() }) }) },
        k = function(n) { var t = i.open({ animation: !0, backdrop: "static", template: "<expenditure-edit-view><\/expenditure-edit-view>", controller: "ExpenditureEditCtrl", windowClass: "expenditure-edit-dialog", resolve: { host: function() { return { type: "browse", id: n } } } }) };
    (function() { t.pageIndex = 1;
        t.pageSize = 15;
        t.search = o;
        t.onPageChanged = l;
        t.switchDate = y;
        t.updateDate = v;
        t.add = p;
        t.edit = w;
        t.browse = k;
        t.deleteData = b;
        a() })() }]);
managementModule.controller("BackupDataContainerCtrl", ["$q", "$log", "$scope", "reportSvc", "enums", "patientUtil", "bizDataBackupLogSvc", function(n, t, i, r, u, f, e) { "use strict"; var o = function() { var t = n.defer(); return r.getNewReportConfig(i.reportName).success(function(n) { t.resolve(n) }), t.promise },
        s = function() { o().then(function(n) { i.reportConfig = n;
                i.$broadcast("reportConfigChange", n) }) },
        h = function(n) { var t = _(i.dataList).pluck("chargeOrderId"),
                r = n ? e.setBackupLogs : e.removeBackupLogs;
            r(e.DataTypes.ChargeOrder, t).then(function() { i.$broadcast("researchReport") }) },
        c = function() { return { onBackupChanged: function(n) { n.isBackup ? e.setBackupLog(e.DataTypes.ChargeOrder, n.chargeOrderId) : e.removeBackupLog(e.DataTypes.ChargeOrder, n.chargeOrderId) } } },
        l = function() { return [{ column: "oper", getTemplate: function() { return i.getColumnTemplate("oper") } }] };
    (function() { i.initReportConfig = s;
        i.preDefinedColumns = l();
        i.preDefinedScope = c();
        i.onPageBackupChanged = h })() }]);
var management;
(function() { "use strict"; var n = function() {
        function n(n, t, i, r) { this.$q = n;
            this.$scope = t;
            this.backgroundTaskSvc = i;
            this.enums = r;
            t.uploadStartTime = moment().subtract(6, "days").format("YYYY-MM-DD");
            t.uploadEndTime = moment().format("YYYY-MM-DD");
            t.pageData = { pageIndex: 1, pageSize: 10, totalCount: 0 } } return n.prototype.searchTask = function() { var n = this,
                i = { pageIndex: n.$scope.pageData.pageIndex, pageSize: n.$scope.pageData.pageSize, taskType: n.enums.BackgroundTaskTypes.ShenzhenHealthBureauDateExport, startTime: this.$scope.uploadStartTime, endTime: this.$scope.uploadEndTime },
                t = n.$q.defer(); return n.backgroundTaskSvc.getBackgroundTasksByType(i).then(function(i) { var r = i.data;
                angular.forEach(r.items, function(t, i) { var u = (r.pageIndex - 1) * r.pageSize + i + 1;
                    t.rowNum = u < 10 ? "0" + u : "" + u;
                    n._formatData(t) });
                n.$scope.pageData = r;
                n.$scope.backgroundTasks = r.items;
                t.resolve(r.items) }).catch(function() { t.reject() }), t.promise }, n.prototype.refreshData = function() { var n = this;
            n.$scope.searchTask().then(function() { n.$scope.refreshGrid() }) }, n.prototype._formatData = function(n) { var t = this;
            n.submitTimeStr = moment(n.submitTime).format("YYYY-MM-DD HH:mm");
            n.startTime && (n.startTimeStr = moment(n.startTime).format("YYYY-MM-DD HH:mm"));
            moment().subtract(30, "days").format("YYYY-MM-DD HH:mm") >= n.startTimeStr && (n.status = t.enums.TaskState.Expired); switch (n.status) {
                case t.enums.TaskState.Completed:
                    n.stateStr = "上传成功";
                    n.stateClass = "complete-tag"; break;
                case t.enums.TaskState.Failed:
                    n.stateStr = "上传失败";
                    n.stateClass = "error-tag"; break;
                default:
                    n.stateStr = "未知";
                    n.stateClass = "error-tag" } }, n.prototype.onPageChanged = function(n) { var t = this;
            t.$scope.pageData.pageIndex = n;
            t.$scope.searchTask().then(function() { t.$scope.refreshGrid() }) }, n.prototype.onPageSizeChanged = function(n) { var t = this;
            t.$scope.pageData.pageSize = n;
            t.$scope.searchTask().then(function() { t.$scope.refreshGrid() }) }, n.$inject = ["$q", "$scope", "backgroundTaskSvc", "enums"], n }();
    managementModule.controller("HealthBureauDataExportShenzhenCtrl", Ares.tsController(n)) })(management || (management = {}));
var management;
(function() { "use strict"; var n = function() {
        function n(n, t, i, r, u, f, e, o, s, h, c) { this.$q = n;
            this.$scope = t;
            this.$state = i;
            this.$interval = r;
            this.loginContext = u;
            this.aresNotification = f;
            this.aresDialog = e;
            this.officeOptionSvc = o;
            this.officeSvc = s;
            this.backgroundTaskSvc = h;
            this.enums = c;
            t.exportDate = moment(new Date).format("YYYY-MM-DD");
            t.pageData = { pageIndex: 1, pageSize: 10, totalCount: 0 };
            t.createTaskButtonDisabled = !0;
            t.isEditHealthBureau = !1;
            t.healthBureauDepartments = [{ code: "D215", name: "口腔诊所" }, { code: "D152", name: "口腔门诊部" }, { code: "A511", name: "口腔亿元" }];
            t.healthBureauDepartment = { code: "", name: "" } } return n.prototype.editOffice = function() { this.$state.go("officeSettings.edit") }, n.prototype.createTask = function() { var n = this,
                t = n.$scope.office,
                i, r, u; if (!t.institutionCode || t.institutionCode.length != 22) { n.aresDialog.warn("机构信息", "按浦东新区社会办医疗机构数据采集要求，数据提交前需要完善机构名称（简称）和机构代码（22位机构代码）"); return } if (i = n.$scope.vpnAccount, !i) { n.aresDialog.info("提示信息", "按浦东新区社会办医疗机构数据采集要求，数据提交前需要完善机构VPN账号"); return } if (!n.$scope.exportDate) { n.aresDialog.info("提示信息", "数据生成日期不能为空"); return } r = !t.abbreviation ? t.name : t.abbreviation;
            u = { taskType: n.enums.BackgroundTaskTypes.PudongHealthBureauDataExport, taskName: r + t.institutionCode + n.$scope.exportDate + ".sql", submitUserId: n.loginContext.userId, submitTime: moment(new Date).format("YYYY-MM-DD HH:mm:ss"), taskParameter: n.$scope.exportDate, status: n.enums.TaskState.Pending };
            n.$scope.getDurationSeconds().then(function(t) { if (t <= 0) n.backgroundTaskSvc.createTask(u).then(function() { n.aresNotification.success("生成任务成功");
                    n.$scope.searchTask().then(function() { n.$scope.refreshGrid() });
                    n.$scope.setRemainTimeString(600) });
                else { var i = Math.ceil(t);
                    n.aresDialog.info("提示信息", "10分钟内不得重复提交,时间剩余" + i + "秒,请耐心等待!") } }) }, n.prototype.reCreateTask = function(n) { var t = this,
                i = _.find(t.$scope.backgroundTasks, function(t) { return t.id == n });
            i || t.aresDialog.info("提示信息", "此记录数据不正确，无法重新生成！");
            i.status = t.enums.TaskState.Pending;
            i.submitTime = moment(new Date).format("YYYY-MM-DD HH:mm:ss");
            i.submitUserId = t.loginContext.userId;
            t.$scope.getDurationSeconds().then(function(n) { if (n <= 0) t.backgroundTaskSvc.createTask(i).then(function() { t.aresNotification.success("重新生成任务成功");
                    t.$scope.searchTask().then(function() { t.$scope.refreshGrid() });
                    t.$scope.setRemainTimeString(600) });
                else { var r = Math.ceil(n);
                    t.aresDialog.info("提示信息", "10分钟内不得重复提交,时间剩余" + r + "秒,请耐心等待!") } }) }, n.prototype.searchTask = function() { var n = this,
                i = { pageIndex: n.$scope.pageData.pageIndex, pageSize: n.$scope.pageData.pageSize, taskType: n.enums.BackgroundTaskTypes.PudongHealthBureauDataExport },
                t = n.$q.defer(); return n.backgroundTaskSvc.getBackgroundTasksByType(i).then(function(i) { var r = i.data;
                angular.forEach(r.items, function(t, i) { var u = (r.pageIndex - 1) * r.pageSize + i + 1;
                    t.rowNum = u < 10 ? "0" + u : "" + u;
                    n._formatData(t) });
                n.$scope.pageData = r;
                n.$scope.backgroundTasks = r.items;
                t.resolve(r.items) }).catch(function() { t.reject() }), t.promise }, n.prototype.refreshData = function() { var n = this;
            n.$scope.searchTask().then(function() { n.$scope.refreshGrid() }) }, n.prototype._formatData = function(n) { var t = this;
            n.submitTimeStr = moment(n.submitTime).format("YYYY-MM-DD HH:mm");
            n.startTime && (n.startTimeStr = moment(n.startTime).format("YYYY-MM-DD HH:mm"));
            moment().subtract(30, "days").format("YYYY-MM-DD HH:mm") >= n.startTimeStr && (n.status = t.enums.TaskState.Expired); switch (n.status) {
                case t.enums.TaskState.Pending:
                case t.enums.TaskState.Processing:
                    n.stateStr = "生成中";
                    n.stateClass = "success-tag"; break;
                case t.enums.TaskState.Completed:
                    n.stateStr = "已下载";
                    n.stateClass = "complete-tag"; break;
                case t.enums.TaskState.Cancelled:
                    n.stateStr = "已取消";
                    n.stateClass = "error-tag"; break;
                case t.enums.TaskState.Failed:
                    n.stateStr = "下载失败";
                    n.stateClass = "error-tag"; break;
                case t.enums.TaskState.Expired:
                    n.stateStr = "已过期";
                    n.stateClass = "error-tag"; break;
                case t.enums.TaskState.Unknown:
                default:
                    n.stateStr = "未知";
                    n.stateClass = "error-tag" } }, n.prototype.getOffice = function() { var n = this,
                i = n.loginContext.officeId,
                t = n.$q.defer(); return n.officeSvc.get(i).then(function(i) { n.$scope.office = i.data;
                t.resolve(i.data) }).catch(function() { t.reject() }), t.promise }, n.prototype.onPageChanged = function(n) { var t = this;
            t.$scope.pageData.pageIndex = n;
            t.$scope.searchTask().then(function() { t.$scope.refreshGrid() }) }, n.prototype.onPageSizeChanged = function(n) { var t = this;
            t.$scope.pageData.pageSize = n;
            t.$scope.searchTask().then(function() { t.$scope.refreshGrid() }) }, n.prototype.getDurationSeconds = function() { var t = this,
                n = t.$q.defer(),
                i = t.enums.BackgroundTaskTypes.PudongHealthBureauDataExport; return t.backgroundTaskSvc.getLastSubmitTime(i).then(function(t) { var i = t.data; if (i) { var r = moment(new Date),
                        u = moment(i),
                        f = moment.duration(r.diff(u)),
                        e = f.asSeconds();
                    n.resolve(600 - e) } else n.resolve(0) }).catch(function() { n.reject() }), n.promise }, n.prototype.setRemainTimeString = function(n) { var t = this,
                i;
            t.$scope.createTaskButtonDisabled = !0;
            n <= 0 ? t.$scope.createTaskButtonDisabled = !1 : (i = parseInt(n + ""), t.$scope.remainTime = Math.floor(i / 60) + ":" + i % 60, t.$scope.interval = t.$interval(function() { t.$scope.remainTime = Math.floor(i / 60) + ":" + i % 60;
                i <= 0 && (t.$scope.createTaskButtonDisabled = !1, t.$interval.cancel(t.$scope.interval), t.$scope.interval = undefined);
                i-- }, 1e3)) }, n.prototype.getHealthBureauVpnAccount = function() { var n = this,
                t = n.$q.defer(),
                i = n.officeOptionSvc.optionKeys.HealthBureauVpnAccount; return n.officeOptionSvc.getOfficeOption(i).then(function(n) { t.resolve(n) }).catch(function() { t.reject() }), t.promise }, n.prototype.getHealthBureauDepartment = function() { var n = this,
                t = n.$q.defer(),
                i = n.officeOptionSvc.optionKeys.HealthBureauDepartmentCode; return n.officeOptionSvc.getOfficeOption(i).then(function(i) { i && (n.$scope.healthBureauDepartment = _.find(n.$scope.healthBureauDepartments, { code: i }));
                t.resolve(i) }).catch(function() { t.reject() }), t.promise }, n.prototype.editHealthBureau = function() { this.$scope.isEditHealthBureau = !0 }, n.prototype.cancelHealthBureau = function() { this.$scope.isEditHealthBureau = !1 }, n.prototype.saveHealthBureau = function() { var n = this,
                t = n.$scope.vpnAccount,
                i, r; if (!t) { n.aresDialog.info("提示信息", "VPN账号不能为空！"); return } i = n.officeOptionSvc.optionKeys.HealthBureauVpnAccount;
            r = [{ optionKey: i, optionValue: t }];
            n.officeOptionSvc.setOfficeOptions(r).then(function() { n.aresNotification.success("保存成功");
                n.$scope.isEditHealthBureau = !1 }) }, n.$inject = ["$q", "$scope", "$state", "$interval", "loginContext", "aresNotification", "aresDialog", "officeOptionSvc", "officeSvc", "backgroundTaskSvc", "enums"], n }();
    managementModule.controller("HealthBureauDataExportCtrl", Ares.tsController(n)) })(management || (management = {}));
managementModule.controller("FollowupAutoRuleListCtrl", ["$q", "$filter", "$timeout", "$scope", "$modal", "followupSvc", "aresNotification", "aresDialog", function(n, t, i, r, u, f) { "use strict"; var e, o = function() { var i = n.defer(),
                t = angular.copy(r.criteria); return t.ruleSubType = t.ruleSubType === "-1" ? null : t.ruleSubType, f.searchFollowupAutoRules(t).then(function(n) { i.resolve(n) }), i.promise },
        s = function(t) { var i = n.defer(); return f.getFollowupAutoRuleById(t).success(function(n) { i.resolve(n) }), i.promise },
        h = function(t) { var r = n.defer(); return e && i.cancel(e), e = i(function() { e = null;
                f.updateList(t).success(function() { r.resolve() }) }, 1e3), r.promise },
        c = function(t) { var i = n.defer(); return f.updateList([t]).success(function() { i.resolve() }), i.promise },
        l = function(n) { return f.deleteRule(n) };
    (function() { r.searchFollowupAutoRules = o;
        r.getFollowupAutoRuleById = s;
        r.updateFollowupAutoRulesOrder = h;
        r.updateFollowupAutoRule = c;
        r.deleteFollowupAutoRule = l })() }]);
managementModule.controller("FollowupConfigCtrl", ["$log", "$filter", "$timeout", "$scope", "$modal", "followupSvc", "aresDialog", function(n, t, i, r, u, f) { "use strict"; var e = function() { f.getFollowupConfig().success(function(n) { n && (r.followupConfig = n) }) },
        o = function() { r.followupConfig = { isAutoFollowupEnabled: !1 } };
    r.save = function() { r.followupConfig || o();
        f.updateFollowupConfig(r.followupConfig).success(function(n) { n && (r.isEdit = !1, e()) }) };
    r.editConfig = function() { r.isEdit = !0 };
    r.cancel = function() { r.isEdit = !1;
            e() },
        function() { r.isEdit = !1;
            e() }() }]);
managementModule.controller("FollowupContentEditCtrl", ["$log", "followupSvc", "$timeout", "$scope", "$modalInstance", "host", function(n, t, i, r, u, f) { "use strict"; var e = function() { r.followupContent.id ? t.update(r.followupContent).success(function(n) { n && u.close(n) }) : t.add(r.followupContent).success(function(n) { n && u.close(n) }) },
        o = function() { u.close() },
        s = function() { r.followupContent || (r.followupContent = { id: "", showOrder: f.maxLength, name: "", type: f.type, content: "" }) };
    (function() { r.title = f.followupContent ? "修改随访" + f.type : "新增随访" + f.type;
        r.followupContent = f.followupContent;
        r.followupContents = f.followupContents;
        r.cancel = o;
        r.save = e;
        s() })() }]);
managementModule.controller("FollowupContentListCtrl", ["$log", "$filter", "$timeout", "$scope", "$modal", "$q", "followupSvc", "aresDialog", "aresNotification", function(n, t, i, r, u, f, e, o, s) { "use strict"; var h = "内容",
        a = function(n) { var t = f.defer(); return e.getAllByType(h).success(function(i) { r.followupContents = i;
                r.refreshGrid(n);
                t.resolve() }), t.promise },
        v = function() { c() },
        y = function(n) { c(n) },
        p = function(n) { e.destroy(n).success(function(t) { if (t) { var i = _.findIndex(r.followupContents, function(t) { return t.id == n });
                    r.followupContents.splice(i, 1);
                    r.refreshGrid() } }).error(function(n) { n.name == "FollowupContentIsExistException" && o.info("提示", "该内容模板关联了随访节点模版，不允许删除!") }) },
        c = function(n) { var t = r.followupContents.length + 1,
                i = u.open({ animation: !0, backdrop: "static", template: "<followup-content-edit-view><\/followup-content-edit-view>", controller: "FollowupContentEditCtrl", size: "lg", windowClass: "small-dialog", resolve: { host: function() { return { type: h, followupContent: n, maxLength: t, followupContents: r.followupContents } } } });
            i.result.then(function(n) { if (n) { var t = _.find(r.followupContents, function(t) { return t.id == n.id });
                    t ? (t.name = n.name, t.content = n.content) : r.followupContents.push(n);
                    r.refreshGrid() } }) },
        l = function(n, t) { t ? n < 0 ? r.isDisableMoveUp = !0 : r.isDisableMoveDown = !0 : n < 0 ? r.isDisableMoveUp = !1 : r.isDisableMoveDown = !1 },
        w = function(n) { var t, i, u; if (r.selectedItem && Ares.ensureNotDuplicated("OnMoveFollowupContent", 1e3) && (t = r.followupContents, i = _.findIndex(t, { id: r.selectedItem.id }), i > -1)) { if (u = i + n, u < 0 || u >= t.length) return; var f = t[i],
                    o = t[u],
                    c = { firstId: f.id, secondId: o.id, type: h };
                l(n, !0);
                e.exchangeShowOrder(c).success(function() { a(!0).then(function() { l(n, !1) }) }).catch(function() { s.error("操作失败，请重试");
                    l(n, !1) }) } };
    (function() { r.add = v;
        r.del = p;
        r.update = y;
        r.openEeitDialog = c;
        r.move = w;
        a(!1) })() }]);
managementModule.controller("FollowupResultListCtrl", ["$log", "$filter", "$timeout", "$scope", "$modal", "followupSvc", function(n, t, i, r, u, f) { "use strict"; var e = "结果",
        s = function(n) { f.getAllByType(e).success(function(t) { r.followupContents = t;
                r.refreshGrid(n) }) },
        h = function() { o() },
        c = function(n) { o(n) },
        l = function(n) { f.destroy(n).success(function(t) { if (t) { var i = _.findIndex(r.followupContents, function(t) { return t.id == n });
                    r.followupContents.splice(i, 1);
                    r.refreshGrid() } }) },
        o = function(n) { var t = r.followupContents.length + 1,
                i = u.open({ animation: !0, backdrop: "static", template: "<followup-content-edit-view><\/followup-content-edit-view>", controller: "FollowupContentEditCtrl", size: "lg", windowClass: "small-dialog", resolve: { host: function() { return { type: e, followupContent: n, maxLength: t, followupContents: r.followupContents } } } });
            i.result.then(function(n) { if (n) { var t = _.find(r.followupContents, function(t) { return t.id == n.id });
                    t ? (t.name = n.name, t.content = n.content) : r.followupContents.push(n);
                    r.refreshGrid() } }) },
        a = function(n) { var t, i, u; if (r.selectedItem && (t = r.followupContents, i = _.findIndex(t, { id: r.selectedItem.id }), i > -1)) { if (u = i + n, u < 0 || u >= t.length) return; var o = t[i],
                    h = t[u],
                    c = { firstId: o.id, secondId: h.id, type: e };
                f.exchangeShowOrder(c).success(function() { s(!0) }) } };
    (function() { r.add = h;
        r.del = l;
        r.update = c;
        r.openEeitDialog = o;
        r.move = a;
        s(!1) })() }]);
managementModule.controller("FollowupRuleEditCtrl", ["$log", "$q", "followupSvc", "aresDialog", "$modal", "$scope", "$modalInstance", "host", "practiceSvc", "shortMessageSvc", "dataDicSvc", function(n, t, i, r, u, f, e, o, s, h, c) { "use strict"; var y = function() { if (g(), f.followupRule.followupRuleConds.length <= 0 && f.isDefaultRule == !1) { r.info("提示", "请选择添加模版内容!"); return } f.followupRule.id ? i.updateRule(f.followupRule).success(function(n) { n && e.close(n) }) : i.addRule(f.followupRule).success(function(n) { n && e.close(n) }) },
        p = function() { e.close() },
        w = function(n) { var t = [],
                i; switch (n) {
                case "chargeItem":
                    t = f.chargeItems; break;
                case "chargeCategory":
                    t = f.chargeTypes; break;
                case "transactioncode":
                    t = f.apptItems; break;
                case "apptCategory":
                    t = f.apptTypes } i = u.open({ animation: !0, backdrop: "static", template: "<item-dialog-view><\/item-dialog-view>", controller: "ItemDialogCtrl", windowClass: "followup-rule-edit-add-dialog", resolve: { host: function() { return { type: n, list: t } } } });
            i.result.then(function(t) { var u, i, r; if (t) { for (u = t.isSaveAll ? ["全部"] : _.pluck(t.obj, "itemName"), i = "", r = 0; r < u.length; r++) { if (i.length > 500) { i += "..."; break } i += u[r] + "," } switch (n) {
                        case "chargeItem":
                            angular.forEach(t.obj, function(n) { n.condType = "chargeItem" });
                            f.chargeItems = t.obj;
                            f.chargeItemNames = i;
                            $("#chargeItem_td").attr("title", i); break;
                        case "chargeCategory":
                            angular.forEach(t.obj, function(n) { n.condType = "chargeCategory" });
                            f.chargeTypes = t.obj;
                            $("#chargeCategory_td").attr("title", i);
                            f.chargeTypeNames = i; break;
                        case "transactioncode":
                            angular.forEach(t.obj, function(n) { n.condType = "transactioncode" });
                            f.apptItems = t.obj;
                            $("#transactioncode_td").attr("title", i);
                            f.apptItemNames = i; break;
                        case "apptCategory":
                            angular.forEach(t.obj, function(n) { n.condType = "apptCategory" });
                            f.apptTypes = t.obj;
                            $("#apptCategory_td").attr("title", i);
                            f.apptTypeNames = i } } }) },
        l = function(n, t) { this.condType = n;
            this.condValue = t },
        b = function() { return [new l("chargeItem", 0), new l("chargeCategory", 0), new l("transactioncode", 0), new l("apptCategory", 0)] },
        k = function() { if (f.todayDate = moment(Ares.today()).format("YYYY-MM-DD"), f.chargeItems = [], f.chargeTypes = [], f.apptItems = [], f.apptTypes = [], f.followupRule) f.isDisable = f.followupRule.ruleName == "重点频繁随访模版" || f.followupRule.ruleName == "多次随访模版" || f.followupRule.ruleName == "两次随访模版" || f.followupRule.ruleName == "诊后默认随访", f.isDefaultRule = f.followupRule.ruleName == "诊后默认随访", f.followupRule.followupRuleActions = _.sortBy(f.followupRule.followupRuleActions, "showOrder"), f.followupRule.followupRuleActions = _.sortBy(f.followupRule.followupRuleActions, "id"), angular.forEach(f.followupRule.followupRuleActions, function(n) { n.unit = n.delay.indexOf("天") > -1 ? "天" : "月";
                n.dueTime = n.delay.replace(n.unit, "") });
            else { var n = _.max(f.followupRules, function(n) { return n.showOrder }),
                    t = n ? n.showOrder + 1 : 1;
                f.followupRule = { id: 0, ruleName: "", showOrder: t, isDefault: 0, isDefaultStr: "自定义", followupRuleConds: b(), followupRuleActions: [], creationMode: 1, timeMode: 1 } } f.isDefaultRule ? (f.chargeItemNames = "全部", f.chargeTypeNames = "全部", f.apptItemNames = "全部", f.apptTypeNames = "全部") : d().then(function() { f.chargeItemNames = a(_.pluck(f.chargeItems, "itemName"));
                f.chargeTypeNames = a(_.pluck(f.chargeTypes, "itemName"));
                f.apptItemNames = a(_.pluck(f.apptItems, "itemName"));
                f.apptTypeNames = a(_.pluck(f.apptTypes, "itemName")) }) },
        a = function(n) { for (var t = "", i = 0; i < n.length; i++) { if (t.length > 500) { t += "..."; break } t += n[i] + "," } return t },
        d = function() { var n = t.defer(); return angular.forEach(f.followupRule.followupRuleConds, function(n) { n.condType == "chargeItem" && n.condValue != 0 && v(n.condType, n.condValue, function(n) { f.chargeItems.push(n) });
                n.condType == "chargeCategory" && n.condValue != 0 && v(n.condType, n.condValue, function(n) { f.chargeTypes.push(n) });
                n.condType == "transactioncode" && n.condValue != 0 && v(n.condType, n.condValue, function(n) { f.apptItems.push(n) });
                n.condType == "apptCategory" && n.condValue != 0 && v(n.condType, n.condValue, function(n) { f.apptTypes.push(n) }) }), n.resolve(!1), n.promise },
        g = function() { f.followupRule.followupRuleConds = [];
            angular.forEach(f.chargeItems, function(n) { f.followupRule.followupRuleConds.push({ condType: n.condType, condValue: n.id }) });
            angular.forEach(f.chargeTypes, function(n) { f.followupRule.followupRuleConds.push({ condType: n.condType, condValue: n.id }) });
            angular.forEach(f.apptItems, function(n) { f.followupRule.followupRuleConds.push({ condType: n.condType, condValue: n.id }) });
            angular.forEach(f.apptTypes, function(n) { f.followupRule.followupRuleConds.push({ condType: n.condType, condValue: n.id }) });
            f.followupRule.followupRuleConds = _.filter(f.followupRule.followupRuleConds, function(n) { return n.condValue != 0 }) },
        v = function(n, t, i) { var r = {},
                u; switch (n) {
                case "chargeItem":
                    u = _.find(f.chargeItemDic, function(n) { return n.id == t });
                    u && (r.id = u.id, r.condType = "chargeItem", r.itemName = u.itemName, i(r)); break;
                case "chargeCategory":
                    u = _.find(f.chargeCategoryDic, function(n) { return n.id == t });
                    u && (r.id = u.id, r.condType = "chargeCategory", r.itemName = u.itemName, i(r)); break;
                case "transactioncode":
                    u = _.find(f.transactionCodeDic, function(n) { return n.id == t });
                    u && (r.id = u.id, r.itemName = u.name, r.condType = "transactioncode", i(r)); break;
                case "apptCategory":
                    f.showType = !1;
                    u = _.find(f.systemsettingDic, function(n) { return n.id == t });
                    u && (r.id = u.id, r.itemName = u.itemName, r.condType = "apptCategory", i(r)) } return r },
        nt = function() { var n = [],
                r; return n.push(c.chargeItemDic.load().then(function(n) { f.chargeItemDic = n })), n.push(c.systemsettingDic.load().then(function(n) { f.systemsettingDic = n })), n.push(c.chargeCategoryDic.load().then(function(n) { f.chargeCategoryDic = n })), n.push(i.getAllByType("内容").success(function(n) { f.followupContents = n })), n.push(c.transactionCodeDic.load().then(function(n) { f.transactionCodeDic = n })), n.push(c.jobDic.load().then(function(n) { f.jobDic = _.map(n, function(n) { return { name: n.itemName, id: n.itemName } }) })), r = t.defer(), t.all(n).then(function() { r.resolve(!0) }), r.promise };
    (function() { f.title = o.followupRule ? "修改随访模版 " : "新增随访模版";
        f.isEdit = o.followupRule ? !0 : !1;
        f.followupRule = o.followupRule;
        f.followupRules = o.followupRules;
        f.cancel = p;
        f.addDetail = w;
        f.save = y;
        nt().then(function() { k();
            f.initView() }) })() }]);
managementModule.controller("FollowupRuleListCtrl", ["$log", "$filter", "$timeout", "$scope", "$modal", "followupSvc", "aresNotification", "aresDialog", function(n, t, i, r, u, f, e, o) { "use strict"; var h, c = !1,
        s = function() { f.getRuleAll().success(function(n) { n.length > 0 && (n = _.filter(n, function(n) { return n.isDefault || !n.isDefault && !n.isInActive }), angular.forEach(n, function(n, t) { n.isDefaultStr = n.isDefault ? "系统" : "自定义";
                    n.isDisabledStr = n.isDisabled ? "禁用" : "启用";
                    n.showOrder = t + 1 }), r.followupRules = n, r.refreshGrid()) }) },
        v = function() { l() },
        y = function(n) { l(n) },
        p = function(n) { n.isDisabled = !0;
            f.updateStatus(n).success(function(n) { n && s() }).error(function() { o.info("提示", "禁用失败!") }) },
        w = function(n) { n.isDisabled = !1;
            f.updateStatus(n).success(function(n) { n && s() }).error(function() { o.info("提示", "启用失败!") }) },
        b = function(n) { f.deleteRule(n).success(function(n) { n && s() }).error(function(n) { n.name == "IsExistFKToFollowupRuleIdException" && o.info("提示", "已存在随访运用该模版，不允许删除!") }) },
        l = function(n) { var t = u.open({ animation: !0, backdrop: "static", template: "<followup-rule-edit-view><\/followup-rule-edit-view>", controller: "FollowupRuleEditCtrl", size: "lg", windowClass: "private-id-rule-list-dialog", resolve: { host: function() { return { followupRule: n, followupRules: r.followupRules } } } });
            t.result.then(function(n) { n && s() }) },
        k = function(n, t) { var i = n.showOrder,
                u, f;
            n.showOrder = t.showOrder;
            t.showOrder = i;
            u = _.find(r.followupRules, function(t) { return t.id == n.id });
            u.showOrder = n.showOrder;
            f = _.find(r.followupRules, function(n) { return n.id == t.id });
            f.showOrder = t.showOrder;
            r.followupRules.splice(i - 1, 1, f);
            r.followupRules.splice(i - 2, 1, u);
            r.refreshUpDownGrid(i);
            c = !0;
            a() },
        d = function(n, t) { var i = n.showOrder,
                u, f;
            n.showOrder = t.showOrder;
            t.showOrder = i;
            u = _.find(r.followupRules, function(t) { return t.id == n.id });
            u.showOrder = n.showOrder;
            f = _.find(r.followupRules, function(n) { return n.id == t.id });
            f.showOrder = t.showOrder;
            r.followupRules.splice(i - 1, 1, f);
            r.followupRules.splice(i, 1, u);
            r.refreshDownGrid(i);
            c = !0;
            a() },
        a = function() { h && i.cancel(h);
            h = i(function() { var n = [];
                angular.forEach(r.followupRules, function(t) { n.push({ id: t.id, showOrder: t.showOrder, isDefault: t.isDefault, ruleName: t.ruleName, isDisabled: t.isDisabled, followupRuleConds: t.followupRuleConds, followupRuleActions: t.followupRuleActions, timeMode: t.timeMode, creationMode: t.creationMode }) });
                f.updateList(n).success(function() { c = !1;
                    s() }) }, 1e3) };
    (function() { r.followupRules = [];
        r.add = v;
        r.del = b;
        r.update = y;
        r.upItem = k;
        r.downItem = d;
        r.disableFollowupRule = p;
        r.enableFollowupRule = w;
        s();
        r.$on("$destroy", function() { if (c) { h && i.cancel(h); var n = [];
                angular.forEach(r.followupRules, function(t) { n.push({ id: t.id, showOrder: t.showOrder, isDefault: t.isDefault, ruleName: t.ruleName }) });
                f.updateList(n) } }) })() }]);
managementModule.controller("FollowupTemplateListCtrl", ["$q", "$filter", "$timeout", "$scope", "$modal", "followupSvc", "aresNotification", "aresDialog", "permissionProvider", function(n, t, i, r, u, f, e, o, s) { "use strict"; var c = function() { var t = n.defer(); return f.searchFollowupTemplates(r.criteria).then(function(n) { t.resolve(n) }), t.promise },
        l = function(t) { var i = n.defer(); return f.getFollowupTemplateById(t).success(function(n) { i.resolve(n) }), i.promise },
        h, a = function(t) { var r = n.defer(); return h && i.cancel(h), h = i(function() { h = null;
                f.updateList(t).success(function() { r.resolve() }) }, 1e3), r.promise },
        v = function(t) { var i = n.defer(); return f.updateList([t]).success(function() { i.resolve() }), i.promise },
        y = function(n) { return f.deleteRule(n) };
    (function() { r.isAllowEdit = s.isAllowed("followup.config");
        r.searchFollowupTemplates = c;
        r.getFollowupTemplateById = l;
        r.updateFollowupTemplatesOrder = a;
        r.updateFollowupTemplate = v;
        r.deleteFollowupTemplate = y })() }]);
managementModule.controller("LastFollowupReportCtrl", ["$log", "$q", "$modal", "$scope", "followupSvc", "aresDialog", "appNav", "practiceSvc", "reportSvc", "enums", "loginContext", "patientSvc", "followupUtil", function(n, t, i, r, u, f, e, o, s, h, c, l, a) { "use strict"; var y, w = function(n) { e.goToPatient(n.patient.id) },
        b = function() { var n = Ares.today(),
                t = moment(n).add(7, "d").toDate();
            y = { startDate: n, endDate: t };
            r.timeSpan = _.clone(y) },
        k = function() { var n = t.defer(); return v(), p().then(function(t) { var i = { totalCount: t.totalCount, items: t.items };
                n.resolve(i) }), n.promise },
        p = function() { var n = t.defer(); return s.getLastFollowupReport(r.criteria).success(function(t) { for (var i = 0; i < t.items.length; i++) t.items[i].lastVisitDateTimeStr = t.items[i].lastVisitDateTime ? moment(t.items[i].lastVisitDateTime).format("YYYY-MM-DD") : "", t.items[i].visitDateTimeStr = t.items[i].visitDateTime ? moment(t.items[i].visitDateTime).format("YYYY-MM-DD") : "";
                r.followupPatList = t.items;
                r.hasFollowup = t.items.length > 0;
                n.resolve(t) }), n.promise },
        v = function() { r.criteria = { startVisitDate: r.defaultSelect ? r.timeSpan.startDate : null, endVisitDate: r.defaultSelect ? moment(r.timeSpan.endDate).add(1, "days").format("YYYY-MM-DD") : null, startLastVisitDate: r.defaultSelect ? null : r.timeSpan.startDate, endLastVisitDate: r.defaultSelect ? null : moment(r.timeSpan.endDate).add(1, "days").format("YYYY-MM-DD"), providerId: r.criteria.providerId || 0, lastProviderId: r.criteria.lastProviderId || 0, keyWord: r.criteria.keyWord, pageIndex: r.pageIndex || 1, pageSize: r.pageSize || 15 } },
        d = function() { var n = t.defer(); return p().then(function(t) { var i = { totalCount: t.totalCount, items: t.items };
                n.resolve(i) }), n.promise },
        g = function(n) { l.getPatientHead(n).then(function(t) { var i = { pid: n, creatorId: c.userId, followupRule: { ruleType: h.FollowupRuleType.ManualRule, creationMode: h.FollowupCreationMode.AllAtOnce, timeMode: h.FollowupTimeMode.Absolute }, appts: [] };
                a.openEditFollowupDialog(i, t).then(function(n) { n && r.refreshGrid() }) }) };
    (function() { r.defaultSelect = !0;
        r.criteria = {};
        r.setCriteria = v;
        r.create = g;
        r.initialize = !0;
        r.goToPatient = w;
        r.refresh = k;
        r.hasFollowup = !0;
        r.init = d;
        b();
        v() })() }]);
managementModule.controller("GroupAutoRevisitRuleCtrl", ["$log", "$scope", "$q", "$modal", "$filter", "$timeout", "$state", "followupSvc", "patientUtil", "aresNotification", "aresDialog", "aresSlidePanel", "enums", "dataDicSvc", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v) { "use strict"; var p = function() { return i.all([b(), k()]) },
        w = function(n, t) { return n.showName = n.ruleName.replace(/#/g, "&nbsp;&nbsp;"), t && t.length > 0 && (n.revisitContent = _.find(angular.copy(t), function(t) { var i = 0; return n.followupRuleActions && n.followupRuleActions.length > 0 && (i = n.followupRuleActions[0].followupContentId), i == t.id })), n.revisitContent || (n.revisitContent = { content: "", followupType: 1, type: "内容", name: name, id: 0 }), n },
        b = function() { var n = i.defer(); return o.getRevisitContentByType("内容").success(function(i) { o.getRevisitRules().success(function(r) { t.revisitRules = _.map(r, function(n) { return w(n, i) });
                    n.resolve(!0) }) }), n.promise },
        k = function() { var n = i.defer(); return v.systemItemDic.loadActive({ itemType: "成交意愿" }).then(function(i) { t.intentions = i;
                n.resolve(!0) }), n.promise },
        y = function(i) { o.saveRevisitRule(i).success(function(n) { n.showName = n.ruleName.replace(/#/g, "&nbsp;&nbsp;");
                n.revisitContent = i.revisitContent; var r = _.findIndex(t.revisitRules, { id: n.id });
                r == -1 ? t.revisitRules.push(n) : t.revisitRules[r] = angular.copy(n);
                t.isChanged = !1;
                e.current._hasConfirmed = !0;
                t.onSelectedRule(n);
                h.success("保存成功") }).error(function(t) { n.log(t);
                h.error("保存失败") }) },
        d = function(i) { var u = !1,
                r = { id: i.id, ruleName: i.ruleName, followupType: 1, isDisabled: i.isDisabled, isDefault: i.isDefault, followupRuleConds: i.followupRuleConds, followupRuleActions: i.followupRuleActions, revisitContent: i.revisitContent, showOrder: i.showOrder },
                f = _.find(t.revisitRules, { id: i.id });
            u = f ? i.revisitContent.content != f.revisitContent.content : i.revisitContent.content && !0;
            u === !0 ? o.saveRevisitContent(i.revisitContent).success(function(n) { r.revisitContent = n;
                r.followupRuleActions[0].followupContentId = n.id;
                y(r) }).error(function(t) { n.log(t);
                h.error("保存失败") }) : y(r) },
        g = function(r) { var u = i.defer(); return o.deleteRule(r).success(function() { t.revisitRules = _.reject(t.revisitRules, function(n) { return n.id == r });
                h.success("删除成功");
                u.resolve(!0) }).error(function(t) { n.log(t);
                h.error("保存失败");
                u.reject(t) }), u.promise };
    (function() { t.initData = p;
        t.save = d;
        t.deleteRule = g })() }]);
managementModule.controller("GroupRevisitListCtrl", ["$log", "$scope", "$q", "$modal", "$filter", "$timeout", "revisitSvc", "patientUtil", "aresNotification", "aresDialog", "enums", "aresModalShelf", function(n, t, i, r, u, f, e, o, s, h, c, l) { "use strict"; var a, y = function() { var n = Ares.today(),
                i = moment(Ares.today()).startOf("month").toDate();
            a = { startDate: i, endDate: n };
            t.timeSpan = _.clone(a) },
        v = function() { var n = i.defer(),
                r = { searchTimeType: t.timeType, startDate: t.timeSpan && t.timeSpan.startDate ? moment(t.timeSpan.startDate).format("YYYY-MM-DD") : null, endDate: t.timeSpan && t.timeSpan.endDate ? moment(t.timeSpan.endDate).add(1, "day").format("YYYY-MM-DD") : null, state: t.revisitState, officeId: t.officeId, pageIndex: t.pageIndex, pageSize: t.pageSize, selectCode: t.selectCode, userId: t.userId, transactionIds: t.transactionIds, visitMethod: t.visitMethod, revisitType: t.revisitType, createdUserId: t.createdUserId }; return r.level = o.getPatientPermissionLevel(), n.resolve(r), n.promise },
        p = function() { var n = i.defer(); return v().then(function(i) { e.getRevisitList(i).success(function(i) { w(i.items);
                    t.pageData = i;
                    n.resolve(t.pageData) }) }), n.promise },
        w = function(n) { for (var t, i = 0; i < n.length; i++) t = n[i], t.index = i + 1, t.id = t.revisitId, t.recordCreatedTimeStr = u("toDateString")(t.recordCreatedTime), t.planTimeStr = u("toLongDateMMString")(t.planTime), t.visitTimeStr = u("toLongDateMMString")(t.visitTime), t.sexStr = u("toSexString")(t.sex), t.ageStr = u("toAgeYearString")(t.birth), t.stateStr = u("toRevisitStateStr")(t.state), t.recordCreatedUserStr = u("toUserName")(t.recordCreatedUser) },
        b = function() { var n = l.open({ title: "新增回访", template: "<customer-revisit-edit-modal-view><\/customer-revisit-edit-modal-view>", controller: "CustomerRevisitEditModalCtrl", resolve: { host: function() { return { isRevisitTask: !1, isEidt: !1, needSearchPatient: !0 } } } });
            n.result.then(function() { t.refreshGrid() }) },
        k = function(n) { var i = n.state == c.RevisitState.Pending.value || n.state == c.RevisitState.Cancelled.value,
                r = l.open({ title: i ? "编辑回访任务" : "编辑回访", template: "<customer-revisit-edit-modal-view><\/customer-revisit-edit-modal-view>", controller: "CustomerRevisitEditModalCtrl", resolve: { host: function() { return { isRevisitTask: i, revisitId: n.revisitId, patientId: n.patientId, isEdit: !0 } } } });
            r.result.then(function() { t.refreshGrid() }) },
        d = function(n) { var i = l.open({ title: "执行回访", template: "<customer-revisit-edit-modal-view><\/customer-revisit-edit-modal-view>", controller: "CustomerRevisitEditModalCtrl", resolve: { host: function() { return { isRevisitTask: !1, revisitId: n.revisitId, patientId: n.patientId, isEdit: !0 } } } });
            i.result.then(function() { t.refreshGrid() }) },
        g = function(n) { h.confirm("信息", "确定要删除吗！").then(function() { e.deleteRevisit(n).success(function() { s.success("删除成功！");
                    t.refreshGrid() }) }) },
        nt = function() { var n = t.pageData ? t.pageData.totalCount : 0;
            t.$parent && t.$parent.refreshDashboardBlockHint && t.$parent.refreshDashboardBlockHint(n) };
    (function() { t.initDefaultTimeSpan = y;
        t.updateCount = nt;
        t.refreshRevisit = p;
        t.createRevisit = b;
        t.editRevisit = k;
        t.executeRevisit = d;
        t.deleteRevisit = g;
        t.initSearchCriteria = v;
        t.userId = -1;
        t.createdUserId = 0;
        t.timeType = 1 })() }]);
managementModule.controller("ChargeItemImportCtrl", ["$log", "$q", "$scope", "$timeout", "enums", "backgroundTaskSvc", "aresNotification", "aresDialog", function(n, t, i, r, u, f, e, o) { "use strict"; var s = function() { f.getBackgroundTasksByType({ TaskType: 5 }).then(function(n) { var t = n.data;
                angular.forEach(t.items, function(n) { h(n) });
                i.backgroundTasks = t.items }) },
        h = function(n) { n.submitTimeStr = moment(n.submitTime).format("YYYY-MM-DD HH:mm:ss");
            n.startTime && (n.startTimeStr = moment(n.startTime).format("YYYY-MM-DD HH:mm:ss")); switch (n.status) {
                case u.TaskState.Unknown:
                    n.stateStr = "未知";
                    n.stateClass = "error-tag"; break;
                case u.TaskState.Pending:
                    n.stateStr = "上传完成";
                    n.stateClass = "success-tag"; break;
                case u.TaskState.Processing:
                    n.stateStr = "正在导入";
                    n.stateClass = "success-tag"; break;
                case u.TaskState.Completed:
                    n.stateStr = "导入成功";
                    n.stateClass = "complete-tag"; break;
                case u.TaskState.Cancelled:
                    n.stateStr = "已取消";
                    n.stateClass = "error-tag"; break;
                case u.TaskState.Failed:
                    n.stateStr = "导入失败";
                    n.stateClass = "error-tag"; break;
                case u.TaskState.Expired:
                    n.stateStr = "已过期";
                    n.stateClass = "error-tag"; break;
                default:
                    n.stateStr = "未知";
                    n.stateClass = "error-tag" } },
        c = function(n) { o.confirm("删除", "确认删除？").then(function() { f.delete(n.id).success(function(n) { n ? (s(), e.success("删除成功")) : e.success("删除失败") }) }) };
    (function() { i.initData = s;
        i.deleteTask = c })() }]);
managementModule.controller("ClueImportCtrl", ["$log", "$q", "$scope", "$timeout", "enums", "backgroundTaskSvc", "aresNotification", "aresDialog", function(n, t, i, r, u, f, e, o) { "use strict"; var c = { pageIndex: 1, pageSize: 20 },
        s = function() { i.searchCriteria.pageIndex = 1;
            f.getBackgroundClueTasks(i.searchCriteria).success(function(n) { i.searchCriteria.pageIndex = n.pageIndex;
                i.backgroundTasksPage = n;
                angular.forEach(i.backgroundTasksPage.items, function(n) { h(n) });
                i.backgroundTasks = n.items }) },
        l = function(n) { i.searchCriteria.pageIndex = n;
            f.getBackgroundClueTasks(i.searchCriteria).success(function(n) { i.searchCriteria.pageIndex = n.pageIndex;
                i.backgroundTasksPage = n;
                angular.forEach(i.backgroundTasksPage.items, function(n) { h(n) });
                i.backgroundTasks = n.items }) },
        h = function(n) { n.submitTimeStr = moment(n.submitTime).format("YYYY-MM-DD HH:mm:ss");
            n.startTime && (n.startTimeStr = moment(n.startTime).format("YYYY-MM-DD HH:mm:ss")); switch (n.status) {
                case u.TaskState.Unknown:
                    n.stateStr = "未知";
                    n.stateClass = "error-tag"; break;
                case u.TaskState.Pending:
                    n.stateStr = "上传完成";
                    n.stateClass = "success-tag"; break;
                case u.TaskState.Processing:
                    n.stateStr = "正在导入";
                    n.stateClass = "success-tag"; break;
                case u.TaskState.Completed:
                    n.stateStr = "导入成功";
                    n.stateClass = "complete-tag"; break;
                case u.TaskState.Cancelled:
                    n.stateStr = "已取消";
                    n.stateClass = "error-tag"; break;
                case u.TaskState.Failed:
                    n.stateStr = "导入失败";
                    n.stateClass = "error-tag"; break;
                case u.TaskState.Expired:
                    n.stateStr = "已过期";
                    n.stateClass = "error-tag"; break;
                default:
                    n.stateStr = "未知";
                    n.stateClass = "error-tag" } },
        a = function(n) { o.confirm("删除", "确认删除？").then(function() { f.delete(n.id).success(function(n) { n ? (s(), e.success("删除成功")) : e.success("删除失败") }) }) };
    (function() { i.initData = s;
        i.deleteTask = a;
        i.searchCriteria = c;
        i.search = l })() }]);
managementModule.controller("PatientImportCtrl", ["$log", "$q", "$scope", "$timeout", "enums", "backgroundTaskSvc", "aresNotification", "aresDialog", function(n, t, i, r, u, f, e, o) { "use strict"; var s = function() { f.getBackgroundTasks().success(function(n) { angular.forEach(n, function(n) { h(n) });
                i.backgroundTasks = n }) },
        h = function(n) { n.submitTimeStr = moment(n.submitTime).format("YYYY-MM-DD HH:mm:ss");
            n.startTime && (n.startTimeStr = moment(n.startTime).format("YYYY-MM-DD HH:mm:ss")); switch (n.status) {
                case u.TaskState.Unknown:
                    n.stateStr = "未知";
                    n.stateClass = "error-tag"; break;
                case u.TaskState.Pending:
                    n.stateStr = "上传完成";
                    n.stateClass = "success-tag"; break;
                case u.TaskState.Processing:
                    n.stateStr = "正在导入";
                    n.stateClass = "success-tag"; break;
                case u.TaskState.Completed:
                    n.stateStr = "导入成功";
                    n.stateClass = "complete-tag"; break;
                case u.TaskState.Cancelled:
                    n.stateStr = "已取消";
                    n.stateClass = "error-tag"; break;
                case u.TaskState.Failed:
                    n.stateStr = "导入失败";
                    n.stateClass = "error-tag"; break;
                case u.TaskState.Expired:
                    n.stateStr = "已过期";
                    n.stateClass = "error-tag"; break;
                default:
                    n.stateStr = "未知";
                    n.stateClass = "error-tag" } },
        c = function(n) { o.confirm("删除", "确认删除？").then(function() { f.delete(n.id).success(function(n) { n ? (s(), e.success("删除成功")) : e.success("删除失败") }) }) };
    (function() { i.initData = s;
        i.deleteTask = c })() }]);
managementModule.controller("SZHealthReportCtrl", ["$log", "$location", "$q", "$scope", "$timeout", "enums", "backgroundTaskSvc", "aresNotification", "aresDialog", function(n, t, i, r, u, f, e, o, s) { "use strict"; var h = t.search().type,
        c = function() { var n = null; switch (h) {
                case "monthly":
                    n = { taskType: 9 }; break;
                case "annual":
                    n = { taskType: 10 } } e.getBackgroundTasksByType(n).success(function(n) { angular.forEach(n.items, function(n) { l(n) });
                r.backgroundTasks = n.items }) },
        l = function(n) { n.submitTimeStr = moment(n.submitTime).format("YYYY-MM-DD HH:mm:ss");
            n.startTime && (n.startTimeStr = moment(n.startTime).format("YYYY-MM-DD HH:mm:ss")); switch (n.status) {
                case f.TaskState.Unknown:
                    n.stateStr = "未知";
                    n.stateClass = "error-tag"; break;
                case f.TaskState.Pending:
                    n.stateStr = "上传完成";
                    n.stateClass = "success-tag"; break;
                case f.TaskState.Processing:
                    n.stateStr = "正在导入";
                    n.stateClass = "success-tag"; break;
                case f.TaskState.Completed:
                    n.stateStr = "导入成功";
                    n.stateClass = "complete-tag"; break;
                case f.TaskState.Cancelled:
                    n.stateStr = "已取消";
                    n.stateClass = "error-tag"; break;
                case f.TaskState.Failed:
                    n.stateStr = "导入失败";
                    n.stateClass = "error-tag"; break;
                case f.TaskState.Expired:
                    n.stateStr = "已过期";
                    n.stateClass = "error-tag"; break;
                default:
                    n.stateStr = "未知";
                    n.stateClass = "error-tag" } },
        a = function(n) { s.confirm("删除", "确认删除？").then(function() { e.delete(n.id).success(function(n) { n ? (c(), o.success("删除成功")) : o.success("删除失败") }) }) };
    (function() { r.type = h;
        r.initData = c;
        r.deleteTask = a })() }]);
managementModule.controller("InvoicePackageCtrl", ["$log", "$timeout", "$filter", "$scope", "$modal", "$q", "invoiceSvc", "aresDialog", "aresNotification", "enums", function(n, t, i, r, u, f, e, o, s, h) { "use strict"; var a = i("getPackageStatusStr"),
        l = i("toLongDateMMString"),
        v = function() { var n = Ares.today(),
                t = moment(Ares.today()).startOf("month").toDate(),
                i = { startDate: t, endDate: n };
            r.timeSpan = _.clone(i) },
        y = function(n) { n == "previous" ? (r.timeSpan.startDate = moment(r.timeSpan.startDate).add(-1, r.selectDate).startOf(r.selectDate).toDate(), r.timeSpan.endDate = moment(r.timeSpan.endDate).add(-1, r.selectDate).endOf(r.selectDate).toDate()) : n == "next" && (r.timeSpan.startDate = moment(r.timeSpan.startDate).add(1, r.selectDate).startOf(r.selectDate).toDate(), r.timeSpan.endDate = moment(r.timeSpan.endDate).add(1, r.selectDate).endOf(r.selectDate).toDate());
            c() },
        p = function(n) { switch (n) {
                case "all":
                    r.timeSpan.startDate = null;
                    r.timeSpan.endDate = null;
                    r.selectDate = "all"; break;
                case "day":
                    r.timeSpan.startDate = moment(Ares.today()).toDate();
                    r.timeSpan.endDate = moment(Ares.today()).toDate();
                    r.selectDate = "day"; break;
                case "week":
                    r.timeSpan.startDate = moment(Ares.today()).startOf("week").toDate();
                    r.timeSpan.endDate = moment(Ares.today()).endOf("week").toDate();
                    r.selectDate = "week"; break;
                case "month":
                    r.timeSpan.startDate = moment(Ares.today()).startOf("month").toDate();
                    r.timeSpan.endDate = moment(Ares.today()).endOf("month").toDate();
                    r.selectDate = "month"; break;
                case "custom":
                    r.timeSpan.endDate || v();
                    r.selectDate = "custom" } c() },
        w = function() { r.searchCriteria = { startTime: null, endTime: null, status: "all" };
            r.page = { index: 1, size: 15 };
            r.selectDate = "all";
            r.timeSpan = {} },
        b = function() { var n = f.defer(); return r.invoicePackageStatusList = [{ name: "全部", value: "all" }, { name: "待发布", value: "0" }, { name: "已发布", value: "1" }, { name: "已作废", value: "2" }, ], n.resolve(), n.promise },
        k = function(n) { return o.confirm("提醒", "确定发布发票包吗？发布后将不能修改规则。").then(function() { return e.publish(n.id).then(function() { s.success("发布成功");
                    c() }).catch(function(n) { var t = n.data;
                    s.error("发布失败 :" + t.message) }) }) },
        d = function(n) { return o.confirm("提醒", "确定撤回发票包？").then(function() { return e.revert(n.id).then(function() { s.success("撤回成功");
                    c() }).catch(function(n) { var t = n.data;
                    s.error("撤回失败:" + t.message) }) }) },
        g = function(n) { return o.confirm("提醒", "确定删除发票包").then(function() { return e.remove(n.id).then(function() { s.success("删除成功");
                    c() }).catch(function(n) { var t = n.data;
                    s.error("删除失败:" + t.message) }) }) },
        c = function() { r.searchCriteria.startTime = r.timeSpan.startDate;
            r.searchCriteria.endTime = r.timeSpan.endDate ? moment(r.timeSpan.endDate).add(1, "day").format("YYYY-MM-DD") : r.timeSpan.endDate;
            r.searchCriteria.pageIndex = r.page.index;
            r.searchCriteria.pageSize = r.page.size;
            r.searchCriteria.isIncludeTimeout = !0;
            e.getPackageBySearchCriteria(r.searchCriteria).then(function(n) { var i = n.data;
                i ? (r.invoicePackages = i.items, r.invoicePackages.forEach(function(n, t) { nt(n, t) })) : r.invoicePackages = [];
                r.page.count = i ? i.pageCount : 1;
                r.page.size = i ? i.pageSize : 1;
                r.page.index = i ? i.pageIndex : 1;
                r.page.totalCount = i ? i.totalCount : 0;
                t(function() { r.initView() }) }) },
        nt = function(n, t) { var i = n.invoiceNoRule;
            n.index = t + 1;
            n.startNumber = i.prefix + Ares.getDigitsNumberStr(i.initialValue, i.seqNumberDigits);
            n.statusStr = a(n.status);
            n.status == h.InvoicePackageStatus.Published && (n.validStartTimeStr = l(n.validStartTime), n.validEndTimeStr = l(n.validEndTime)) },
        tt = function() { if (!r.timeSpan.startDate || !r.timeSpan.endDate) { s.error("发票导出必须选择时间！"); return } var n = moment(r.timeSpan.startDate).add(1, "day").format("YYYY-MM-DD"),
                t = moment(r.timeSpan.endDate).add(1, "day").format("YYYY-MM-DD");
            e.exportXmlInvoices(n, t) };
    (function() { r.switchDate = p;
        r.updateDate = y;
        r.searchInvoicePackages = c;
        r.removeUpdate = g;
        r.pubilshUpdate = k;
        r.revertUpdate = d;
        r.exportInvoices = tt;
        b().then(function() { w();
            c() }) })() }]);
managementModule.controller("medicalExamListCtrl", ["$log", "$q", "$scope", "$timeout", "$filter", "reportSvc", "dataDicSvc", "aresNotification", "permissionProvider", "loginContext", "reportUtil", function(n, t, i, r, u, f, e, o, s, h, c) { "use strict"; var a = u("toMedicalExamTypeStr"),
        v = u("toMedicalExamSubTypeStr"),
        y = function() { var n = Ares.today(),
                t = moment(Ares.today()).startOf("month").toDate(),
                r = { startDate: t, endDate: n };
            i.timeSpan = _.clone(r) },
        p = function(n) { n == "previous" ? (i.timeSpan.startDate = moment(i.timeSpan.startDate).add(-1, i.selectDate).toDate(), i.timeSpan.endDate = moment(i.timeSpan.endDate).add(-1, i.selectDate).toDate()) : n == "next" && (i.timeSpan.startDate = moment(i.timeSpan.startDate).add(1, i.selectDate).toDate(), i.timeSpan.endDate = moment(i.timeSpan.endDate).add(1, i.selectDate).toDate());
            l() },
        w = function(n) { switch (n) {
                case "all":
                    i.timeSpan.startDate = null;
                    i.timeSpan.endDate = null;
                    i.selectDate = "all"; break;
                case "day":
                    i.timeSpan.startDate = moment(Ares.today()).toDate();
                    i.timeSpan.endDate = moment(Ares.today()).add(1).toDate();
                    i.selectDate = "day"; break;
                case "week":
                    i.timeSpan.startDate = moment(Ares.today()).startOf("week").toDate();
                    i.timeSpan.endDate = moment(Ares.today()).endOf("week").toDate();
                    i.selectDate = "week"; break;
                case "month":
                    i.timeSpan.startDate = c.getDefaultTimeSpan().startTime;
                    i.timeSpan.endDate = c.getDefaultTimeSpan().endTime;
                    i.selectDate = "month"; break;
                case "custom":
                    i.timeSpan.endDate || y();
                    i.selectDate = "custom" } l() },
        b = function() { i.searchCriteria = { startDate: null, endDate: null, doctorId: -1, nurseId: -1, searchText: "" };
            i.page = { index: 1, size: 15 };
            i.selectDate = "all";
            i.timeSpan = {} },
        l = function() { i.searchCriteria.startDate = i.timeSpan.startDate ? moment(i.timeSpan.startDate).format("YYYY-MM-DD") : i.timeSpan.startDate;
            i.searchCriteria.endDate = i.timeSpan.endDate ? moment(i.timeSpan.endDate).add(1, "day").format("YYYY-MM-DD") : i.timeSpan.endDate;
            i.searchCriteria.pageIndex = i.page.index;
            i.searchCriteria.pageSize = i.page.size;
            i.isDoctor ? i.searchCriteria.doctorId = h.providerId : i.isAssistant && (i.searchCriteria.nurseId = h.providerId);
            f.searchMedicalExamPagedList(i.searchCriteria).then(function(n) { var t = n.data;
                i.medicalExamList = t.items;
                k(i.medicalExamList);
                i.page.count = t.pageCount;
                i.page.size = t.pageSize;
                i.page.index = t.pageIndex;
                i.page.totalCount = t.totalCount;
                i.initView() }) },
        k = function(n) { angular.forEach(n, function(n) { n.examTypeStr = a(n.examType);
                n.examSubTypeStr = v(n.examSubType) }) };
    (function() { i.switchDate = w;
        i.updateDate = p;
        i.searchMedicalExamPagedList = l;
        i.initSearchCriteriaData = b })() }]);
managementModule.controller("MemoListCtrl", ["$log", "$scope", "$q", "$filter", "loginContext", "memoSvc", "eventAggregator", "aresDialog", "multiOfficeDataDic", function(n, t, i, r, u, f, e, o, s) { "use strict"; var h = function() { var n = i.defer(),
                r = u.officeId; return s.loadDic(r, "currentOfficeWorkProviderDic").then(function(i) { t.providers = i;
                n.resolve(!0) }), n.promise },
        c = function(n) { var o = i.defer(),
                u = t.timeStatus,
                f = t.providerType,
                e = t.providerId,
                r = { pageSize: t.pageSize, status: t.status, subject: t.subject, isImportant: t.isImportant, pageIndex: n ? 1 : t.pageIndex }; return f == 1 ? r.recordCreatedUser = e : f == 2 ? r.assigneeProviderId = e : f == 3 && (r.completeProviderId = e), u == 1 ? (r.startCompleteTime = t.startTime, r.endCompleteTime = t.endTime) : u == 2 ? (r.startRemindTime = t.startTime, r.endRemindTime = t.endTime) : u == 3 && (r.startCreateTime = t.startTime, r.endCreateTime = t.endTime), o.resolve(r), o.promise },
        l = function(n) { var r = i.defer(); return c(n).then(function(n) { f.searchMemo(n).success(function(n) { t.pageData = n;
                    r.resolve(t.pageData) }) }), r.promise },
        a = function() { e.subscribe(t, e.events.MemoActionChanged, function() { t.search() }) };
    (function() { t.memoData = {};
        t.pageSize = 20;
        t.pageIndex = 1;
        t.refreshListData = l;
        t.initProviders = h;
        a() })() }]);
managementModule.controller("OrganizationBusinessCtrl", ["$log", "$scope", "$q", "$filter", "loginContext", "orgmanagementSvc", function(n, t, i, r, u, f) { "use strict"; var e = function(n) { var r = i.defer(),
                u = { pageSize: t.pageSize, pageIndex: n ? 1 : t.pageIndex, isDisabled: t.isDisabled }; return r.resolve(u), r.promise },
        o = function(n) { var r = i.defer(); return e(n).then(function(n) { f.queryJobTitle(n).success(function(n) { t.pageData = n;
                    r.resolve(t.pageData) }) }), r.promise },
        s = function(n) { var t = i.defer(); return f.enableJobTitle(n).then(function(n) { t.resolve(n.data) }), t.promise },
        h = function(n) { var t = i.defer(); return f.disableJobTitle(n).then(function(n) { t.resolve(n.data) }), t.promise },
        c = function(n) { var t = i.defer(); return f.canDisableJobTitle(n).then(function(n) { t.resolve(n.data) }), t.promise };
    (function() { t.pageSize = 20;
        t.pageIndex = 1;
        t.refreshListData = o;
        t.enableJobTitle = s;
        t.disableJobTitle = h;
        t.canDisableJobTitle = c })() }]);
managementModule.controller("OrganizationDepartmentCtrl", ["$log", "$scope", "$q", "$filter", "loginContext", "orgmanagementSvc", function(n, t, i, r, u, f) { "use strict"; var e = function(n) { var r = i.defer(),
                u = t.departmentTypes,
                f = { pageSize: t.pageSize, pageIndex: n ? 1 : t.pageIndex, isDisabled: t.isDisabled, departmentTypes: u > -1 ? u : null }; return r.resolve(f), r.promise },
        o = function(n) { var r = i.defer(); return e(n).then(function(n) { f.queryDepartment(n).success(function(n) { t.pageData = n;
                    r.resolve(t.pageData) }) }), r.promise },
        s = function(n) { var t = i.defer(); return f.enableDepartment(n).then(function(n) { t.resolve(n.data) }), t.promise },
        h = function(n) { var t = i.defer(); return f.disableDepartment(n).then(function(n) { t.resolve(n.data) }), t.promise };
    (function() { t.pageSize = 20;
        t.pageIndex = 1;
        t.refreshListData = o;
        t.enableDepartment = s;
        t.disableDepartment = h })() }]);
managementModule.controller("OrganizationOrgmanagementCtrl", ["$log", "$scope", "$q", "orgmanagementSvc", "practiceSvc", "loginContext", function(n, t, i, r, u, f) { "use strict"; var e = function(n) { var t = i.defer(); return r.deleteProviderJobTitle(n).success(function(n) { t.resolve(n) }), t.promise },
        o = function() { var n = i.defer(); return u.getFullOffice(f.officeId).success(function(i) { t.officeInfo = i;
                n.resolve(!0) }), n.promise };
    (function() { t.deleteProvider = e;
        t.getOffice = o })() }]);
managementModule.controller("DentureProductsEditCtrl", ["$log", "$scope", "$location", "$modalInstance", "$http", "$state", "aresDialog", "appNav", "practiceSvc", "dataDicSvc", "enums", "constants", "loginContext", "host", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v) { "use strict";
    t.dentureProducts = {};
    t.cancel = function() { r.dismiss("cancel") };
    t.saveDenture = function() { t.dentureProducts.id ? s.updateDentureProducts(t.dentureProducts).success(function(n) { t.showNotification("保存成功！");
            r.close(n) }).error(function() {}) : s.addDentureProducts(t.dentureProducts).success(function(n) { t.showNotification("保存成功！");
            r.close(n) }).error(function() {}) };
    t.initDentureTypeDropDown = function() { s.getItemTypes("义齿类别").success(function(n) { var r, i; if ((t.productCatagoryList = n, $("#productCatagory").kendoNameCodeFilterComboBox({ dataSource: n, filter: "contains", placeholder: "请选择义齿类别", dataTextField: "itemName", dataValueField: "id", select: function(n) { var i = this.dataItem(n.item.index());
                        t.$apply(t.dentureProducts.productCatagory = i.itemName) } }), r = $("#productCatagory").data("kendoNameCodeFilterComboBox"), r) && t.dentureProducts && t.dentureProducts.productCatagory)
                for (i = 0; i < n.length; ++i)
                    if (n[i].itemName == t.dentureProducts.productCatagory) { r.select(i); break } }) }; var y = function() { var i = h.systemsettingDic.data(),
            n; for (t.processMethodList = [], t.repairTypeList = [], t.materialList = [], n = 0; n < i.length; ++n) i[n].itemType == "技加工方式" ? t.processMethodList.push(i[n]) : i[n].itemType == "技加工修复形式" ? t.repairTypeList.push(i[n]) : i[n].itemType == "技加工材料" && t.materialList.push(i[n]) };
    t.dentureId = v.dentureId;
    y();
    t.dentureId > 0 ? s.getDentureProductsById(t.dentureId).success(function(n) { t.dentureProducts = n;
        t.initDentureTypeDropDown() }) : (t.dentureProducts = { id: 0, productCatagory: "固定义齿", dentureType: "", dentureProduct: "", factoryName: "", unit: "", price: 0, isDefault: !1 }, t.initDentureTypeDropDown()) }]);
managementModule.controller("PentureProductsCtrl", ["$log", "$filter", "$timeout", "$scope", "$modal", "appNav", "constants", "reportSvc", "dashboardSvc", "formatUtil", "shortMessageUtil", "patientSvc", "practiceSvc", "aresDialog", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v) { "use strict"; var y = function() { a.getDentureProducts().success(function(n) { for (var t = 0; t < n.length; t++) n[t].index = t + 1;
                r.dentureProductsList = n }) },
        p = function() { var n = u.open({ animation: !0, backdrop: "static", template: "<denture-products-edit-view><\/denture-products-edit-view>", controller: "DentureProductsEditCtrl", size: "md", resolve: { host: function() { return { dentureId: 0 } } } });
            n.result.then(function() { y() }) },
        w = function(n) { var t = u.open({ animation: !0, backdrop: "static", template: "<denture-products-edit-view><\/denture-products-edit-view>", controller: "DentureProductsEditCtrl", size: "md", resolve: { host: function() { return { dentureId: n.id } } } });
            t.result.then(function() { y() }) },
        b = function(n) { v.confirm("提示", "确定要删除此产品？").then(function() { a.deleteDentureProducts(n.id).success(function() { r.showNotification("删除成功！");
                    y() }) }) };
    (function() { y();
        r.createFactory = p;
        r.updateFactory = w;
        r.deleteFactory = b })() }]);
managementModule.controller("OutprocessFactoryCtrl", ["$log", "$filter", "$timeout", "$scope", "$modal", "appNav", "constants", "reportSvc", "dashboardSvc", "formatUtil", "shortMessageUtil", "patientSvc", "practiceSvc", "aresDialog", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v) { "use strict"; var y = function() { a.getOutProcessFactory().success(function(n) { for (var t = 0; t < n.length; t++) n[t].index = t + 1;
                r.outprocessFactoryList = n }) },
        p = function() { var n = u.open({ animation: !0, backdrop: "static", template: "<outprocess-factory-edit-dialog><\/outprocess-factory-edit-dialog>", controller: "OutprocessFactoryEditCtrl", size: "md", resolve: { host: function() { return { factoryId: 0 } } } });
            n.result.then(function() { y() }) },
        w = function(n) { var t = u.open({ animation: !0, backdrop: "static", template: "<outprocess-factory-edit-dialog><\/outprocess-factory-edit-dialog>", controller: "OutprocessFactoryEditCtrl", size: "md", resolve: { host: function() { return { factoryId: n.id } } } });
            t.result.then(function() { y() }) },
        b = function(n) { v.confirm("提示", "确定要删除此工厂？").then(function() { a.deleteOutProcessFactory(n.id).success(function() { r.showNotification("删除成功！");
                    y() }) }) };
    (function() { y();
        r.createFactory = p;
        r.updateFactory = w;
        r.deleteFactory = b })() }]);
managementModule.controller("OutprocessorderBorwserCtrl", ["$q", "$log", "$timeout", "$scope", "appNav", "sessionCache", "reportSvc", "practiceSvc", "patientSvc", "dataDicSvc", "loginContext", "printUtil", function(n, t, i, r, u, f, e, o, s, h, c, l) { "use strict";
    r.outProcessOrderCriteria = {}; var a, v = f.getCache(f.keys.outProcessOrderCacheCriteria),
        b = function(n) { u.goToPatient(n.patient.id) },
        k = function() { var n = Ares.today(),
                t = moment(n).add(1, "d").toDate();
            a = { startDate: n, endDate: t };
            r.timeSpan = _.clone(a) },
        y = function() { var n = moment(r.outProcessOrderCriteria.startDate).format("YYYY-MM-DD"),
                t = moment(r.outProcessOrderCriteria.endDate).format("YYYY-MM-DD");
            r.outProcessOrderCriteria.doctorId && r.outProcessOrderCriteria.doctorId <= 0 && (r.outProcessOrderCriteria.doctorId = -1);
            e.getOutprocessorderList(n, t, r.outProcessOrderCriteria.doctorId || -1, r.outProcessOrderCriteria.stateName || -1, r.outProcessOrderCriteria.supplyName || -1, r.isBySendDate).success(function(n) { for (var t = 0; t < n.length; t++) n[t].startTime && (n[t].startTime = moment(n[t].startTime).format("YYYY-MM-DD HH:mm")), n[t].sendDate && (n[t].sendDate = moment(n[t].sendDate).format("YYYY-MM-DD HH:mm")), n[t].backDate && (n[t].backDate = moment(n[t].backDate).format("YYYY-MM-DD HH:mm"));
                r.outprocessorderList = n;
                r.hasFollowup = n.length > 0 }) },
        d = function() { p();
            v.saveObject(r.outProcessOrderCriteria);
            y();
            w() },
        g = function() { p(); var n = v.loadObject();
            n && _.extend(r.outProcessOrderCriteria, n);
            r.timeSpan.startDate = moment(r.outProcessOrderCriteria.startDate).toDate();
            r.timeSpan.endDate = moment(r.outProcessOrderCriteria.endDate).add(-1, "d").toDate() },
        p = function() { var n, t;
            $("#daysBeforeTodayInput").val() == "自定义" ? (r.outProcessOrderCriteria.dateType = "自定义", n = r.timeSpan.startDate, t = moment(r.timeSpan.endDate).add(1, "d")) : $("#daysBeforeTodayInput").val() == "0" ? (r.outProcessOrderCriteria.dateType = "0", n = Ares.today(), t = moment(n).add(1, "d").toDate()) : $("#daysBeforeTodayInput").val() == "1" && (r.outProcessOrderCriteria.dateType = "1", n = moment(Ares.today()).add(1, "d").toDate(), t = moment(n).add(1, "d").toDate());
            r.outProcessOrderCriteria.startDate = moment(n).format("YYYY-MM-DD");
            r.outProcessOrderCriteria.endDate = moment(t).format("YYYY-MM-DD") },
        nt = function() { o.getDoctors().success(function(n) { var t = n;
                t.splice(0, 0, { id: -1, name: "全部" });
                $("#doctorInput").kendoDropDownList({ dataSource: t, placeholder: "", dataTextField: "name", dataValueField: "id", value: r.outProcessOrderCriteria.doctorId, select: function(n) { var t = this.dataItem(n.item.index());
                        i(function() { r.outProcessOrderCriteria.doctorId = t.id });
                        Ares.sensors.trackDropDownEvent("OutprocessorderBorwser", "医生") } }) }) },
        tt = function() { o.getOutProcesser().success(function(n) { var t = n;
                t.splice(0, 0, { id: -1, itemName: "全部" });
                $("#supplyers").kendoDropDownList({ dataSource: t, placeholder: "请选择加工厂商", dataTextField: "itemName", dataValueField: "id", value: r.outProcessOrderCriteria.supplyId, select: function(n) { var t = this.dataItem(n.item.index());
                        i(function() { r.outProcessOrderCriteria.supplyName = t.itemName == "全部" ? -1 : t.itemName;
                            r.outProcessOrderCriteria.supplyId = t.id });
                        Ares.sensors.trackDropDownEvent("OutprocessorderBorwser", "加工厂商") } }) }) },
        it = function() { o.getItemTypes("技加工状态").success(function(n) { var t = n;
                t.splice(0, 0, { id: -1, itemName: "全部" });
                $("#stateInput").kendoDropDownList({ dataSource: t, placeholder: "", dataTextField: "itemName", dataValueField: "id", value: r.outProcessOrderCriteria.stateId, select: function(n) { var t = this.dataItem(n.item.index());
                        i(function() { r.outProcessOrderCriteria.stateName = t.itemName == "全部" ? -1 : t.itemName;
                            r.outProcessOrderCriteria.stateId = t.id });
                        Ares.sensors.trackDropDownEvent("OutprocessorderBorwser", "技加工状态") } }) }) },
        rt = function(n) { n.find("tr").each(function(n, t) { if ($("td:last", t).html(""), n > 1) { var i = r.outprocessorderList[n - 2].itemNameStr;
                    $("td:last", t).html(i) } }) },
        w = function() { r.gridClone = $("#outprocessorderList").clone(); var n = r.gridClone;
            n.find("table tbody tr.k-detail-row").remove();
            n.find("table tr th:last").text("技加工项目").css("color", "#551a8b");
            n.find("table tr th:first").remove();
            n.find("table tr th:first").attr("colspan", "2");
            rt(n) },
        ut = function() { var n = { title: "", payDate: null, payType: "", printTime: null },
                i = h.officeDic.getItemSync(c.officeId),
                t;
            n.title = i.name + "技加工管理";
            n.printTime = moment().format("YYYY.MM.DD HH:mm:ss");
            n.payDate = r.outProcessOrderCriteria.startDate + " - " + r.outProcessOrderCriteria.endDate;
            t = r.gridClone;
            t.css("width", "1000px");
            l.printSkillProcessGrid(n, t) };
    (function() { r.goToPatient = b;
        r.refresh = d;
        r.print = ut;
        r.hasFollowup = !0;
        r.isBySendDate = !1;
        r.initGridClone = w;
        k();
        g();
        y();
        r.dropOptions = { value: r.outProcessOrderCriteria.dateType };
        nt();
        tt();
        it() })() }]);
managementModule.controller("PersonalChargeDetailCtrl", ["$log", "$scope", "reportSvc", "formatUtil", "sessionCache", "aresDialog", "loginContext", "reportUtil", function(n, t, i, r, u, f, e, o) { "use strict"; var h = u.getCache(u.keys.ChargeDetailSearchCriteria),
        c, s = [];
    t.gridColumns = []; var a = function() { c = o.getDefaultTimeSpan(!0);
            t.timeSpan = _.clone(c) },
        v = function() { t.criteria = { startDate: t.timeSpan.startTime, endDate: t.timeSpan.endTime, doctorId: e.providerJob == "医生" ? e.providerId : "-1", statusType: "全部", nurseId: e.providerJob == "护士" ? e.providerId : "-1" }; var n = h.loadObject();
            n && (_.extend(t.criteria, n), t.criteria.defaultSelect && (t.defaultSelect = !0, t.timeSpan.startTime = moment(t.criteria.startDate).toDate(), t.timeSpan.endTime = moment(t.criteria.startDate).toDate()), t.criteria.defaultSelect == !1 && (t.defaultSelect = !1, t.timeSpan.startTime = moment(t.criteria.startDate).toDate(), t.timeSpan.endTime = moment(t.criteria.endDate).toDate())) },
        l = function() { i.GetPersonalDoctorCharge(t.criteria.statusType, t.criteria.startDate, t.criteria.endDate, t.criteria.doctorId, t.criteria.nurseId).success(function(n) { p(n);
                s = []; for (var i = 0; i < n.length; i++) s.push(n[i].payType), s.push(n[i].payType2), s.push(n[i].payType3), n[i][n[i].payType] = n[i].actualPrice1, n[i][n[i].payType2] = n[i].actualPrice2, n[i][n[i].payType3] = n[i].actualPrice3;
                y(n);
                t.pageData = n }) },
        y = function(n) { var r = [],
                e, f, o, i, u; for (t.gridColumns = [], t.aggregate = [], t.aggregate.push({ field: "actualPrice", aggregate: "sum" }, { field: "patientName", aggregate: "count" }), e = 1, u = 0; u < s.length; ++u) { for (f = s[u], o = !1, i = 0; i < r.length; i++)
                    if (r[i].type == f) { o = !0; break } o == !1 && f != null && f != "" && (r.push({ index: "p" + e, type: f }), e++) } for (i = 0; i < r.length; i++) { for (u = 0; u < n.length; u++) n[u][r[i].index] || (n[u][r[i].index] = 0), n[u][r[i].type] && (n[u][r[i].index] = n[u][r[i].type]);
                t.gridColumns.push({ field: r[i].index, title: r[i].type, headerTemplate: r[i].type, width: "150px", format: "{0:n}", aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" });
                t.aggregate.push({ field: r[i].index, aggregate: "sum" }) } },
        p = function(n) { angular.forEach(n, function(n) { n.status == "退费" && (n.shouldPayPrice = n.actualPrice, n.overdue = 0) });
            r.formatList(n, { billTime: "longDateTime", payTime: "longDateTime" }) },
        w = function() { b();
            l() },
        b = function() { var n = o.getStartEndTime(t);
            t.criteria = { startDate: n.start, endDate: n.end, doctorId: e.providerJob == "医生" ? e.providerId : "-1", statusType: $("#statusInput").val(), nurseId: e.providerJob == "护士" ? e.providerId : "-1", defaultSelect: t.defaultSelect };
            h.saveObject(t.criteria) },
        k = function() { v();
            l() };
    t.radioCharge = function(n) { t.timeSpan = o.getDefaultTimeSpan(n) },
        function() { t.defaultSelect = !0;
            t.search = w;
            a();
            k() }() }]);
managementModule.controller("PersonalConsultantWorkSummaryReportCtrl", ["$log", "$q", "$scope", "reportSvc", "formatUtil", "loginContext", "reportUtil", function(n, t, i, r, u, f, e) { "use strict"; var o, h = function() { o = e.getDefaultTimeSpan(!0);
            i.timeSpan = _.clone(o) },
        c = function() { var n = e.getStartEndTime(i),
                t = i.job == "咨询师" ? 1 : 2,
                o = { startDate: n.start, endDate: n.end, providerId: f.providerId, providerType: t, tagIds: null, orderMinDiscount: 0, orderMaxDiscount: 100, privateTag: i.privateTag, isDealed: i.isDealed };
            r.getProviderWorkSummaryReport(o).success(function(n) { angular.forEach(n, function(n) { n.tagStr && (n.tagStr = n.tagStr.substring(0, n.tagStr.length - 1), n.tagStr = n.tagStr.substring(1));
                    n.startTime = moment(n.startTime).format("YYYY-MM-DD HH:mm");
                    n.payDateTime = moment(n.payDateTime).format("YYYY-MM-DD HH:mm");
                    n.isChargedStr = n.isCharged ? "已充值" : "未充值";
                    u.formatAppt(n) });
                i.pageData = n }) },
        s = function() { c() };
    (function() { i.defaultSelect = !0;
        i.search = s;
        i.privateTag = "";
        h();
        s();
        i.$watch("defaultSelect", function() { i.timeSpan = e.getDefaultTimeSpan(i.defaultSelect) }) })() }]);
managementModule.controller("PersonalNetworkConsultantWorkSummaryReportCtrl", ["$log", "$scope", "$modal", "$q", "$filter", "reportSvc", "formatUtil", "shortMessageUtil", "practiceSvc", "patientUtil", "aresNotification", "loginContext", "aresDialog", "dataDicSvc", "providerSvc", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y) { "use strict"; var w = function() { var n = r.defer(),
                i = p(); return f.getNetworkConsultantWorkSummary(i).success(function(i) { t.searchData = i;
                n.resolve(i) }), n.promise },
        p = function() { var n = t.timeSpan.startDate ? moment(t.timeSpan.startDate).format("YYYY-MM-DD") : t.timeSpan.startDate,
                i = t.timeSpan.endDate ? moment(t.timeSpan.endDate).add(1, "day").format("YYYY-MM-DD") : t.timeSpan.endDate; return { startDate: n, endDate: i, searchText: t.searchText, searchStatus: t.currentToggleTab, providerIds: t.consultantIds, officeIds: t.isGroup ? t.selectedIdsStr : l.officeId, transactionCodeIds: t.transactionCodes, chargeItemIds: t.chargeItemIds, createdUserProviderIds: t.selectedCreatedUserId || "", pageIndex: t.pageIndex, pageSize: t.pageSize, isApptTime: t.defaultSelect, checkInType: t.checkInType } },
        b = function() { var r = p(),
                n, i;
            t.performanceGrid && (n = t.performanceGrid.columns, i = { criteria: r, columns: n }, f.exportNetworkConsultantWorkSummary(i)) },
        k = function() { var n = r.defer(),
                i = t.selectedOfficeId ? t.selectedOfficeId : ""; return y.getCreatedUserProviderByOnlineConsultantIds(t.consultantIds, i).success(function(t) { n.resolve(t) }), n.promise };
    (function() { t.searchPerformanceList = w;
        t.exportPersonalWorkSummary = b;
        t.getCreatedUserByConsultant = k })() }]);
managementModule.controller("PersonalPerformanceChargeCategoryCtrl", ["$log", "$timeout", "$scope", "$modal", "dataDicSvc", "reportSvc", "aresDialog", "$q", "practiceSvc", "loginContext", "reportUtil", function(n, t, i, r, u, f, e, o, s, h, c) { "use strict"; var l, w = function() { l = c.getDefaultTimeSpan(!0);
            i.timeSpan = _.clone(l) },
        a = function() { var n = o.defer(),
                t = c.getStartEndTime(i),
                r = { providerIdStr: h.providerId, chargeItemIdStr: null, departmentIdStr: null, providerType: h.providerJob === "医生" ? "doctor" : "nurse", superType: i.selectSuperType, startTime: t.start, endTime: t.end }; return f.getDoctorChargeCategoryReportData(r).success(function(t) { var r = t.dataLoad;
                i.showOverflowWarning = t.overflow;
                i.count = r ? r.length : 0;
                i.pageData = r;
                n.resolve(!0) }).error(function(t) { e.error("发生了一个错误", t.message);
                n.resolve(!1) }), n.promise },
        b = function() { a().then(function() { v().then(function() { y();
                    p() }) }) },
        v = function() { var t = o.defer(),
                n = []; return angular.forEach(i.pageData, function(t) { n.indexOf(t.itemName) === -1 && n.push(t.itemName) }), i.chargeCategorys = n, t.resolve(!0), t.promise },
        k = function() { w();
            a("load").then(function() { v().then(function() { y();
                    p() }) }) },
        y = function() { var n = h.providerJob === "护士" ? "护士" : "医生";
            i.gridColumns = [{ field: "providerName", title: n, width: "100px", footerTemplate: "总计" }];
            angular.forEach(i.chargeCategorys, function(n, t) { i.gridColumns.push({ field: "column" + t, title: n, headerTemplate: n, attributes: { style: "padding: 0" }, width: "120px", format: "{0:n}", aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'n2')#" }) });
            i.gridColumns.push({ field: "totalPrice", title: "金额", headerTemplate: "金额", attributes: { style: "padding: 0" }, width: "150px", format: "{0:n}", aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'n2')#" }) },
        p = function() { var s = [],
                u = [],
                e = [],
                r, t, o, n, h, f, c; for (angular.forEach(i.pageData, function(n) { u.indexOf(n.providerName) === -1 && u.push(n.providerName) }), r = 0; r < u.length; r++) { for (t = {}, t.providerName = u[r], o = 0, n = 0; n < i.chargeCategorys.length; n++) h = i.chargeCategorys[n], f = _.filter(i.pageData, function(n) { return n.itemName === h && n.providerName === u[r] }), f ? (c = i.selectActualPrice ? _.pluck(f, "actualPrice") : _.pluck(f, "planPrice"), t["column" + n] = _.reduce(c, function(n, t) { return n + t }, 0), o += t["column" + n]) : t["column" + n] = 0, r === 0 && e.push({ field: "column" + n, aggregate: "sum" });
                t.totalPrice = o;
                s.push(t) } e.push({ field: "totalPrice", aggregate: "sum" });
            i.dataSource = s;
            i.aggregate = e };
    (function() { i.defaultSelect = !0;
        i.selectActualPrice = !0;
        i.selectSuperType = !1;
        i.search = b;
        k();
        i.$watch("defaultSelect", function() { i.timeSpan = c.getDefaultTimeSpan(i.defaultSelect) }) })() }]);
managementModule.controller("PersonalPerformanceChargeClassCtrl", ["$log", "$filter", "$scope", "$modal", "appNav", "reportSvc", "practiceSvc", "loginContext", function(n, t, i, r, u, f, e, o) { "use strict"; var c, l = function() { var n = Ares.today(),
            t = moment(n).add(-1, "week").toDate();
        c = { startDate: t, endDate: n };
        i.timeSpan = _.clone(c) };
    i.chargeOrderSimpleDetailList = {};
    i.chargeOrder = {}; var a = function() { var n, t;
            $("#daysBeforeTodayInput").val() == "自定义" ? (n = i.timeSpan.startDate, t = moment(i.timeSpan.endDate).add(1, "d")) : $("#daysBeforeTodayInput").val() == "week" ? (n = moment(Ares.today()).startOf("week"), t = moment(Ares.today()).add(1, "d")) : $("#daysBeforeTodayInput").val() == "month" ? (n = moment(Ares.today()).startOf("month"), t = moment(Ares.today()).add(1, "d")) : (n = moment(Ares.today()).add(-$("#daysBeforeTodayInput").val(), "d"), t = moment(Ares.today()).add(1, "d"));
            o.providerJob == "护士" ? e.getChargeOrderSimpleDetailByNurse(n, t, o.providerId).success(function(r) { i.chargeOrderSimpleDetailList = r;
                e.getChargeOrderByTime(n, t).success(function(r) { i.chargeOrder = r;
                    e.getChargeCategory().success(function(r) { i.chargeItemCatagories = r;
                        f.personalGetNurseChargeDetails(n, t, o.providerId).success(function(n) { i.chargeDetailList = n;
                            v() }) }) }) }) : e.getChargeOrderSimpleDetailByDoctor(n, t, o.providerId).success(function(r) { i.chargeOrderSimpleDetailList = r;
                e.getChargeOrderByTime(n, t).success(function(r) { i.chargeOrder = r;
                    e.getChargeCategory().success(function(r) { i.chargeItemCatagories = r;
                        f.personalGetChargeDetails(n, t, o.providerId).success(function(r) { i.chargeDetailList = r;
                            f.personalGetCdtChargeItem(n, t, o.providerId).success(function(n) { i.chargeDetailListCdt = n;
                                y() }) }) }) }) }) },
        v = function() { var ut = [],
                v = [],
                d, u, nt, tt, y, e, c, it, p, a, w, f, b, r, rt, k, t, l, n; if (i.chargeDetailList) { for (d = { finalprice: 0, actualprice: 0 }, u = {}, n = 0; n < i.chargeItemCatagories.length; n++) i.chargeItemCatagories[n].index = "p" + (n + 1), d[i.chargeItemCatagories[n].index] = 0, v.push({ field: i.chargeItemCatagories[n].index, title: i.chargeItemCatagories[n].itemName, headerTemplate: i.chargeItemCatagories[n].itemName, width: "80px", format: "{0:n}" });
                v.push({ field: "finalprice", title: "应收总额(折扣后)", width: "80px", format: "{0:n}" });
                v.push({ field: "actualprice", title: "实收总额", width: "80px", format: "{0:n}" });
                u = s(d); var h = [],
                    ft = [],
                    g = []; for (t = 0; t < i.chargeOrder.length; ++t)
                    if (r = i.chargeOrder[t], r.nurseId == 0) ft.push(r);
                    else { for (nt = !1, n = 0; n < h.length; n++)
                            if (h[n].name == r.nurseName) { nt = !0;
                                h[n].children.push(r); break } nt == !1 && (tt = { name: r.nurseName, id: r.nurseId, children: [] }, tt.children.push(r), h.push(tt)) } for (y = [], e = [], t = 0; t < h.length; t++) h[t].id == o.providerId && e.push(h[t]); for (c = [], t = 0; t < g.length; t++) g[t].id == o.providerId && c.push(g[t]); if (c.length != 0)
                    if (e.length == 0) e.push(c[0]);
                    else
                        for (t = 0; t < c[0].children.length; t++) { for (it = !1, n = 0; n < e[0].children.length; n++)
                                if (c[0].children[t].chargeOrderId == e[0].children[n].id) { it = !0; break } it || y.push(c[0].children[t]) }
                for (t = 0; t < y.length; t++) e[0].children.push(y[t]); for (p = 0; p < e.length; p++) { for (a = e[p], u.nurseId = a.id, u.nurseName = a.name, w = 0; w < a.children.length; w++)
                        if (f = a.children[w], f.orderType == "simple") { for (u.actualprice += f.actualPrice * 1, b = 0; b < i.chargeOrderSimpleDetailList.length; b++)
                                if (r = i.chargeOrderSimpleDetailList[b], r) { for (rt = !0, k = 0; k < i.chargeDetailList.length; k++)
                                        if (i.chargeDetailList[k].chargeOrderId == r.chargeOrderId) { rt = !1; break } if (rt && r.chargeOrderId == f.id)
                                        for (u.finalprice += r.totalPrice * r.discount / 100, n = 0; n < i.chargeItemCatagories.length; n++) i.chargeItemCatagories[n].itemName == r.chargeType && (u[i.chargeItemCatagories[n].index] += r.totalPrice * r.discount / 100) } } else if (f.orderType != "cdt")
                        if (f.orderType == "detail") { for (u.actualprice += f.actualPrice * 1, t = 0; t < i.chargeDetailList.length; t++)
                                if (l = i.chargeDetailList[t], l && l.chargeOrderId == f.id && (u.finalprice += l.finalprice * 1, i.chargeItemCatagories))
                                    for (n = 0; n < i.chargeItemCatagories.length; n++) i.chargeItemCatagories[n].id == l.itemCatagoryId && (u[i.chargeItemCatagories[n].index] += l.finalprice * 1) } else f.orderType == "reimburse" && (u.actualprice += f.actualPrice * 1);
                    u.nurseId == o.providerId && ut.push(u) } } i.pageData = ut;
            i.gridColumns = v },
        y = function() { var ut = [],
                w = [],
                tt, u, v, y, b, h, a, it, k, p, d, e, g, r, rt, nt, t, f, n; if (i.chargeDetailList) { for (tt = { finalprice: 0, actualprice: 0 }, u = {}, n = 0; n < i.chargeItemCatagories.length; n++) i.chargeItemCatagories[n].index = "p" + (n + 1), tt[i.chargeItemCatagories[n].index] = 0, w.push({ field: i.chargeItemCatagories[n].index, title: i.chargeItemCatagories[n].itemName, headerTemplate: i.chargeItemCatagories[n].itemName, width: "80px", format: "{0:n}" });
                w.push({ field: "finalprice", title: "应收总额(折扣后)", width: "80px", format: "{0:n}" });
                w.push({ field: "actualprice", title: "实收总额", width: "80px", format: "{0:n}" });
                u = s(tt); var c = [],
                    ft = [],
                    l = []; for (t = 0; t < i.chargeOrder.length; ++t)
                    if (r = i.chargeOrder[t], r.doctorId == 0) ft.push(r);
                    else { for (v = !1, n = 0; n < c.length; n++)
                            if (c[n].name == r.doctorName) { v = !0;
                                c[n].children.push(r); break } v == !1 && (y = { name: r.doctorName, id: r.doctorId, children: [] }, y.children.push(r), c.push(y)) } for (t = 0; t < i.chargeDetailListCdt.length; ++t)
                    if (r = i.chargeDetailListCdt[t], r.doctorId != null) { for (v = !1, n = 0; n < l.length; n++)
                            if (l[n].name == r.doctorName) { v = !0;
                                l[n].children.push(r); break } v == !1 && (y = { name: r.doctorName, id: r.doctorId, children: [] }, y.children.push(r), l.push(y)) } for (b = [], h = [], t = 0; t < c.length; t++) c[t].id == o.providerId && h.push(c[t]); for (a = [], t = 0; t < l.length; t++) l[t].id == o.providerId && a.push(l[t]); if (a.length != 0)
                    if (h.length == 0) h.push(a[0]);
                    else
                        for (t = 0; t < a[0].children.length; t++) { for (it = !1, n = 0; n < h[0].children.length; n++)
                                if (a[0].children[t].chargeOrderId == h[0].children[n].id) { it = !0; break } it || b.push(a[0].children[t]) }
                for (t = 0; t < b.length; t++) h[0].children.push(b[t]); for (k = 0; k < h.length; k++) { for (p = h[k], u.doctorId = p.id, u.doctorName = p.name, d = 0; d < p.children.length; d++)
                        if (e = p.children[d], e.orderType == "simple") { for (u.actualprice += e.actualPrice, g = 0; g < i.chargeOrderSimpleDetailList.length; g++)
                                if (r = i.chargeOrderSimpleDetailList[g], r) { for (rt = !0, nt = 0; nt < i.chargeDetailList.length; nt++)
                                        if (i.chargeDetailList[nt].chargeOrderId == r.chargeOrderId) { rt = !1; break } if (rt && r.chargeOrderId == e.id)
                                        for (u.finalprice += r.totalPrice * r.discount / 100, n = 0; n < i.chargeItemCatagories.length; n++) i.chargeItemCatagories[n].itemName == r.chargeType && (u[i.chargeItemCatagories[n].index] += r.totalPrice * r.discount / 100) } } else if (e.orderType == "cdt") { for (t = 0; t < i.chargeDetailListCdt.length; t++)
                            if (f = i.chargeDetailListCdt[t], f.doctorName == u.doctorName && f && f.doctorId != null && f.id == e.id && (u.finalprice += f.totalPrice * 1, u.actualprice += f.totalPrice * 1, i.chargeItemCatagories))
                                for (n = 0; n < i.chargeItemCatagories.length; n++) i.chargeItemCatagories[n].id == f.chargeItemId && (u[i.chargeItemCatagories[n].index] += f.totalPrice * 1) } else if (e.orderType == "detail") { for (u.actualprice += e.actualPrice, t = 0; t < i.chargeDetailList.length; t++)
                            if (f = i.chargeDetailList[t], f && f.chargeOrderId == e.id && (u.finalprice += f.finalprice * 1, i.chargeItemCatagories))
                                for (n = 0; n < i.chargeItemCatagories.length; n++) i.chargeItemCatagories[n].id == f.itemCatagoryId && (u[i.chargeItemCatagories[n].index] += f.finalprice * 1) } else e.orderType == "reimburse" && (u.actualprice += e.actualPrice);
                    u.doctorId == o.providerId && ut.push(u) } } i.pageData = ut;
            i.gridColumns = w },
        s = function(n) { var i = {}; for (var t in n) i[t] = typeof n[t] == "object" ? s(n[t]) : n[t]; return i },
        h = function(n) { i.pageIndex = n;
            a(i.pageIndex, i.pageSize) },
        p = function() { h(1) };
    (function() { i.pageIndex = 1;
        i.pageSize = 100;
        i.maxPageCount = 10;
        i.onPageChanged = h;
        i.search = p;
        l();
        h(1) })() }]);
managementModule.controller("PersonalPerformanceDoctorApptCtrl", ["$log", "loginContext", "$scope", "$modal", "aresDialog", "reportSvc", "reportUtil", function(n, t, i, r, u, f, e) { "use strict"; var o, h = function() { o = e.getDefaultTimeSpan(!0);
            i.timeSpan = _.clone(o) },
        c = function(n) { return n && n.length > 0 && (i.columns = [{ field: "doctorName", title: "医生姓名", width: "100px", footerTemplate: "总计" }, { field: "totalVisitCnt", title: "总诊次数", width: "100px", aggregates: ["sum"], footerTemplate: "#=sum#" }, { field: "totalAmount", title: "总金额", width: "100px", aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }], i.aggregates = [{ field: "totalVisitCnt", aggregate: "sum" }, { field: "totalAmount", aggregate: "sum" }], n[0].checkIns.forEach(function(n, t) { i.columns.push({ field: "vGroupCnt" + t, title: n.name + "次数", width: "100px", aggregates: ["sum"], footerTemplate: "#=sum#" }, { field: "vGroupAmount" + t, title: n.name + "金额", width: "100px", aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" });
                i.aggregates.push({ field: "vGroupCnt" + t, aggregate: "sum" }, { field: "vGroupAmount" + t, aggregate: "sum" }) }), n.forEach(function(n) { n.checkIns.forEach(function(t, i) { Object.defineProperty(n, "vGroupCnt" + i, { value: t.count, enumerable: !0 });
                    Object.defineProperty(n, "vGroupAmount" + i, { value: t.amount, enumerable: !0 }) }) })), n },
        s = function() { var n = e.getStartEndTime(i);
            f.getDoctorApptCountReport(n.start, n.end, t.providerId, !0).success(function(n) { i.pageData = c(n) }) },
        l = function() { s() };
    (function() { i.defaultSelect = !0;
        i.selectActualPrice = !0;
        i.search = l;
        i.columns = [];
        i.aggregates = [];
        h();
        s("load");
        i.$watch("defaultSelect", function() { i.timeSpan = e.getDefaultTimeSpan(i.defaultSelect) }) })() }]);
managementModule.controller("PersonalPerformanceChargeDetailCtrl", ["$log", "loginContext", "$scope", "$modal", "dataDicSvc", "reportSvc", "aresDialog", "reportUtil", function(n, t, i, r, u, f, e, o) { "use strict"; var s, c = function() { s = o.getDefaultTimeSpan(!0);
            i.timeSpan = _.clone(s) },
        h = function() { var n = o.getStartEndTime(i),
                r = { providerIdStr: t.providerId, providerType: t.providerJob === "医生" ? "doctor" : "nurse", chargeItemIdStr: null, departmentIdStr: null, startTime: n.start, endTime: n.end },
                u;
            i.chargeItems.length > 0 && i.chargeItemNames !== "全部" && (u = _.pluck(i.chargeItems, "id"), r.chargeItemIdStr = u.join());
            l(r) },
        l = function(n) { f.getDoctorChargeReportData(n).success(function(n) { var t = n.dataLoad;
                i.count = t ? t.length : 0;
                i.showOverflowWarning = n.overflow;
                a(t);
                i.pageData = t }).error(function(n) { e.error("发生了一个错误", n.message) }) },
        a = function(n) { angular.forEach(n, function(n) { n.actualPrice = n.actualPrice || 0;
                n.planPrice = n.planPrice || 0;
                n.itemName === "退费" && (n.planPrice = n.actualPrice);
                n.actualPrice = Ares.priceToFixed(n.actualPrice);
                n.planPrice = Ares.priceToFixed(n.planPrice) }) },
        v = function() { h() },
        y = function() { u.chargeItemDic.load().then(function(n) { i.chargeItems = n }) },
        p = function() { var n = angular.copy(i.chargeItems),
                t = r.open({ animation: !0, backdrop: "static", template: "<item-dialog-view><\/item-dialog-view>", controller: "ItemDialogCtrl", windowClass: "followup-rule-edit-add-dialog", resolve: { host: function() { return { type: "chargeItem", list: n } } } });
            t.result.then(function(n) { var u, t, r; if (n) { for (u = n.isSaveAll ? ["全部"] : _.pluck(n.obj, "itemName"), t = "", r = 0; r < u.length; r++) { if (t.length > 10) { t += "..."; break } t += u[r] + "," } i.chargeItemNames = t === "" || t === "全部," ? "全部" : t;
                    angular.forEach(n.obj, function(n) { n.condType = "chargeItem" });
                    i.chargeItems = n.obj } }) };
    (function() { i.chargeItems = [];
        i.chargeItemNames = "全部";
        i.defaultSelect = !0;
        i.selectActualPrice = !0;
        i.showOverflowWarning = !1;
        i.openDialog = p;
        i.search = v;
        y();
        c();
        h("load");
        i.$watch("defaultSelect", function() { i.timeSpan = o.getDefaultTimeSpan(i.defaultSelect) }) })() }]);
managementModule.controller("PatientReferralReportCtrl", ["$log", "$scope", "loginContext", "$q", "reportSvc", "dataDicSvc", "officeSvc", "officeSelectorUtil", function(n, t, i, r, u, f, e, o) { "use strict"; var s = function() { var n = r.defer(),
                f = t.criteria; return f.officeIds = t.isGroup ? t.selectedOfficeIdsArray : [i.officeId], u.getPatientReferralReport(f).success(function(t) { n.resolve(t) }), n.promise },
        h = function() { var n = r.defer(),
                u = [f.officeDic.load().then(function(n) { t.offices = n })]; return t.isGroup && u.push(e.getSelfAndChildOfficesByGroupId(i.officeId, !0).success(function(n) { t.officeTreeData = o.setId(n); var i = _.values(o.flattenToMap(n));
                t.selectedOfficeIdsArray = _.pluck(i, "officeId") })), r.all(u).then(function() { n.resolve(!0) }), n.promise };
    (function() { t.isGroup = i.isGroup;
        t.loadOffices = h;
        t.getPatientReferral = s;
        t.criteria = { pageIndex: 1, pageSize: 20 } })() }]);
managementModule.controller("PatientReferralRewardReportCtrl", ["$log", "$scope", "$q", "reportSvc", function(n, t, i, r) { "use strict"; var u = function() { var n = i.defer(),
                t = f(); return r.getPatientReferralRewardReport(t).success(function(t) { n.resolve(t) }), n.promise },
        f = function() { var n = t.criteria,
                i = t.timeSpan; return i && (i = angular.copy(i), t.isTotalPaymentRuleType ? (n.orderTimeStart = i.startDate, n.orderTimeEnd = moment(i.endDate).add(1, "days").format("YYYY-MM-DD")) : (n.visitTimeStart = i.startDate, n.visitTimeEnd = moment(i.endDate).add(1, "days").format("YYYY-MM-DD"))), n.ruleType = t.ruleType, n.patientId = t.patient ? t.patient.id : null, n.refereeId = t.referee ? t.referee.id : null, n };
    (function() { t.getPatientReferralReward = u;
        t.criteria = { pageIndex: 1, pageSize: 20 } })() }]);
managementModule.controller("PatientReferralVisitReportCtrl", ["$log", "$scope", "$q", "reportSvc", "loginContext", "dataDicSvc", "officeSvc", "officeSelectorUtil", function(n, t, i, r, u, f, e, o) { "use strict"; var s = function() { var n = i.defer(),
                t = h(); return r.getPatientReferralVisitReport(t).success(function(t) { n.resolve(t) }), n.promise },
        h = function() { var i = t.criteria,
                n = t.firstVisitTimeSpan; return n && (n = angular.copy(n), i.firstVisitStart = n.startDate, i.firstVisitEnd = moment(n.endDate).add(1, "days").format("YYYY-MM-DD")), n = t.lastVisitTimeSpan, n && (n = angular.copy(n), i.lastVisitStart = n.startDate, i.lastVisitEnd = moment(n.endDate).add(1, "days").format("YYYY-MM-DD")), n = t.createdTimeSpan, n && (n = angular.copy(n), i.createdTimeStart = n.startDate, i.createdTimeEnd = moment(n.endDate).add(1, "days").format("YYYY-MM-DD")), i.officeIds = t.isGroup ? t.selectedOfficeIdsArray : [u.officeId], i },
        c = function() { var n = i.defer(),
                r = [f.officeDic.load().then(function(n) { t.offices = n })]; return t.isGroup && r.push(e.getSelfAndChildOfficesByGroupId(u.officeId, !0).success(function(n) { t.officeTreeData = o.setId(n); var i = _.values(o.flattenToMap(n));
                t.selectedOfficeIdsArray = _.pluck(i, "officeId") })), i.all(r).then(function() { n.resolve(!0) }), n.promise };
    (function() { t.isGroup = u.isGroup;
        t.loadOffices = c;
        t.getPatientReferralVisit = s;
        t.criteria = { pageIndex: 1, pageSize: 20 } })() }]);
var management;
(function(n) { "use strict"; var t, i;
    (function(n) { n.ReferralCountRank = "ReferralCountRankReport";
        n.ReferralChargeAmountRank = "ReferralChargeAmountRankReport";
        n.ReferralCountTrend = "ReferralCountTrendReport";
        n.ReferralChargeAmountTrend = "ReferralChargeAmountTrendReport" })(t = n.ReportName || (n.ReportName = {}));
    i = function() {
        function n(n, i, r, u, f, e, o, s, h) { var c;
            this.$scope = n;
            this.reportUtil = i;
            this.customizeReportSvc = r;
            this.reportSvc = u;
            this.loginContext = f;
            this.$q = e;
            this.moduleOptionProvider = o;
            this.$timeout = s;
            this.$filter = h;
            this.initDateRange();
            this.toFormatPriceFilter = h("toFormatPrice");
            n.uiState = { chartStates: (c = {}, c[t.ReferralCountTrend] = { noData: !1 }, c[t.ReferralChargeAmountTrend] = { noData: !1 }, c) } } return n.prototype.initDateRange = function() { var n, i = this.reportUtil.getDefaultDateRange("year"),
                r = moment(i.startDate).format("YYYY-MM-DD"),
                u = moment(i.endDate).format("YYYY-MM-DD");
            this.$scope.dateRangeMap = (n = {}, n[t.ReferralCountTrend] = { startDate: r, endDate: u }, n[t.ReferralChargeAmountTrend] = { startDate: r, endDate: u }, n) }, n.prototype.onReferralCountDateRangeChanged = function(n) { this._onDateRangeChanged(t.ReferralCountTrend, n) }, n.prototype.onReferralAmountDateRangeChanged = function(n) { this._onDateRangeChanged(t.ReferralChargeAmountTrend, n) }, n.prototype.loadSummaryReport = function() { var n = this,
                t = this.$q.defer(); return this.reportSvc.getReferralSummaryReport().success(function(i) { i ? i.sumAmount = n._formatPrice(i.sumAmount) : i = { refererCount: 0, refereeCount: 0, sumAmount: 0 };
                n.$scope.referralSummary = i;
                t.resolve() }), t.promise }, n.prototype.loadRankReport = function() { this.search(t.ReferralCountRank, !0, null, null);
            this.search(t.ReferralChargeAmountRank, !0, null, null) }, n.prototype.loadTrendReport = function() { this.search(t.ReferralCountTrend, !0, this.$scope.dateRangeMap[t.ReferralCountTrend].startDate, this.$scope.dateRangeMap[t.ReferralCountTrend].endDate);
            this.search(t.ReferralChargeAmountTrend, !0, this.$scope.dateRangeMap[t.ReferralChargeAmountTrend].startDate, this.$scope.dateRangeMap[t.ReferralChargeAmountTrend].endDate) }, n.prototype.search = function(n, t, i, r) { this.loadReport(n, t, i, r) }, n.prototype.loadReport = function(n, i, r, u) { var f = this;
            this._searchReport(n, i, r, u).then(function(i) { switch (n) {
                    case t.ReferralCountRank:
                        f.$scope.referralCountRankData = f._fillRankData(i, !1); break;
                    case t.ReferralChargeAmountRank:
                        f.$scope.referralAmountRankData = f._fillRankData(i, !0); break;
                    case t.ReferralCountTrend:
                        f.$scope.initReferralCountTrend(i.items); break;
                    case t.ReferralChargeAmountTrend:
                        f.$scope.initReferralAmountTrend(i.items) } }) }, n.prototype._searchReport = function(n, t, i, r) { var u = this.$q.defer(); return this.$scope.searchCriteria = { reportName: n, isSingleOffice: t, officeId: this.loginContext.officeId, startDate: i, endDate: r }, this.customizeReportSvc.searchChartOverviewReport(this.$scope.searchCriteria).success(function(n) { u.resolve(n) }), u.promise }, n.prototype._formatPrice = function(n) { var t = this.toFormatPriceFilter(n); return t === "---" ? t : "￥" + t }, n.prototype._onDateRangeChanged = function(n, t) { this.$scope.dateRangeMap[n] = t || this.$scope.dateRangeMap[n];
            this.search(n, !0, this.$scope.dateRangeMap[n].startDate, this.$scope.dateRangeMap[n].endDate) }, n.prototype._fillRankData = function(n, t) { var r = this,
                i = []; return n != null && _.each(n.items, function(n) { var u = n.items;
                _.each(u, function(n) { n.value = t ? r.toFormatPriceFilter(n.value) : n.value;
                    i.push(n) }) }), i }, n.$inject = ["$scope", "reportUtil", "customizeReportSvc", "reportSvc", "loginContext", "$q", "moduleOptionProvider", "$timeout", "$filter"], n }();
    supplychainReportModule.controller("ReferralReportDashboardCtrl", Ares.tsController(i)) })(management || (management = {}));
managementModule.directive("complaintEditView", ["$log", "$q", "$timeout", "$modal", "practiceSvc", function(n, t, i, r, u) { return { replace: !0, templateUrl: "/app/management/dialogs/complaint-edit-dialog/complaint-edit-view.html", link: function(n, t) { var o = function() { t.parents(".modal-dialog").css("width", "576px");
                    i(function() { Ares.centerModal(t.closest(".modal-dialog")) }, 50) },
                f = function(i) { var i = t.find("#" + i).kendoDropDownList({ dataSource: [{ name: "现场", value: 1 }, { name: "电话", value: 2 }, { name: "其他", value: 3 }], dataTextField: "name", dataValueField: "value", value: i == "feedbackMethod" ? n.complaint.feedbackMethod : null }).data("kendoDropDownList") },
                s = function() { var i = t.find("#severity").kendoDropDownList({ dataSource: [{ name: "请选择严重程度", value: null }, { name: "低", value: 1 }, { name: "中", value: 2 }, { name: "高", value: 3 }], dataTextField: "name", dataValueField: "value", value: n.complaint.severity || null }).data("kendoDropDownList") },
                h = function() { var i = t.find("#assigneeProvider");
                    i.kendoDropDownList({ dataSource: n.providers, filter: "contains", dataTextField: "name", dataValueField: "id", optionLabel: "请选择被投诉人", value: n.complaint.targetProviderId || null }) },
                e = function() { u.getItemTypes(n.itemType).success(function(i) { var r = t.find("#category"),
                            u = r.kendoDropDownList({ dataSource: i, dataTextField: "itemName", dataValueField: "itemName", optionLabel: "请选择主题", value: n.complaint ? n.complaint.category : null, select: function() { Ares.sensors.trackDropDownEvent("ComplaintEdit", "投诉主题") } }) }) },
                c = function() { var i = t.find("#satisfaction").kendoDropDownList({ dataSource: [{ name: "请选择满意度", value: null }, { name: "满意", value: 1 }, { name: "不满意", value: 2 }], dataTextField: "name", dataValueField: "value", value: n.complaint.satisfaction || null }).data("kendoDropDownList") },
                l = function() { s();
                    e();
                    c();
                    n.complaint.complaintMethod = n.complaint.complaintMethod || 1;
                    n.complaint.feedbackMethod = n.complaint.feedbackMethod || 1;
                    f("complaintMethod");
                    f("feedbackMethod");
                    n.initProviders().then(function() { h() }) },
                a = function() { var t = r.open({ animation: !0, backdrop: "static", template: "<system-setting-item-edit><\/system-setting-item-edit>", controller: "SystemSettingItemEditCtrl", resolve: { host: function() { return { itemType: n.itemType } }, boxTitle: function() { return "" } } });
                    t.result.then(function(n) { n && e() }) };
            (function() { n.editCategory = a;
                n.itemType = "投诉主题";
                o();
                n.initData().then(function() { l() }) })() } } }]);
managementModule.controller("ComplaintEditCtrl", ["$log", "$q", "$timeout", "$scope", "$modalInstance", "host", "complaintSvc", "multiOfficeDataDic", "loginContext", "aresNotification", "eventAggregator", "patientSvc", function(n, t, i, r, u, f, e, o, s, h, c, l) { "use strict"; var y = function() { u.dismiss() },
        p = function() { var n = t.defer(),
                i = s.officeId; return o.loadDic(i, "currentOfficeWorkProviderDic").then(function(t) { r.providers = t;
                n.resolve(!0) }), n.promise },
        w = function() { var n = t.defer(),
                i = f.complaintId; return i ? e.getComplaint(i).success(function(t) { r.complaint = t;
                g(t);
                n.resolve(!0) }) : (r.complaint = { state: 1 }, n.resolve(!0)), n.promise },
        b = function() { var n = tt(),
                t = f.complaintId;
            n && (t ? d() : k()) },
        k = function() { a();
            e.addComplaint(r.complaint).success(function(n) { nt(n);
                u.close(n) }) },
        d = function() { a();
            e.updateComplaint(r.complaint).success(function(n) { u.close(n) }) },
        g = function(n) { if (n.recordProviderId == s.providerId && (r.editSelf = !0), n.processProviderId == s.providerId && (r.processSelf = !0), n.sourcePatientId) { var t = { id: n.sourcePatientId };
                v(t) } },
        a = function() { r.patient && (r.complaint.sourcePatientId = r.patient.id) },
        nt = function(n) { i(function() { c.publish(c.events.ComplaintActionChanged, n, "ComplaintEditCtrl") }, 500) },
        tt = function() { var t = r.complaint,
                i = r.patient,
                n = !0; return t.complaintMethod || (h.error("请选择投诉方式！"), n = !1), t.severity || (h.error("请选择严重程度！"), n = !1), _.isEmpty(t.category) && (h.error("请选择主题！"), n = !1), _.isEmpty(t.content) && (h.error("请输入投诉内容！"), n = !1), n },
        it = function() { var n = f.type;
            r.editType = n;
            n == "add" ? r.title = "新增投诉" : n == "process" ? r.title = "投诉处理" : n == "feedback" ? r.title = "投诉反馈" : n == "detail" && (r.title = "投诉查看") },
        v = function(n) { r.patient = n;
            r.isPatientExisted = n != null && n.id > 0;
            r.isPatientExisted && l.getPatient(r.patient.id).success(function(n) { r.patient = n }) };
    (function() { r.cancel = y;
        r.save = b;
        r.initData = w;
        r.initProviders = p;
        r.onPatientSelected = v;
        it() })() }]);
managementModule.directive("customerClueAllocationView", ["$log", "$q", "$timeout", "$modal", "practiceSvc", function(n, t, i) { return { replace: !0, templateUrl: "/app/management/dialogs/customer-clue-allocation-dialog/customer-clue-allocation-view.html", link: function(n, t) { var r = function() { t.parents(".modal-dialog").css("width", "576px");
                i(function() { Ares.centerModal(t.closest(".modal-dialog")) }, 50) };
            (function() { r() })() } } }]);
managementModule.controller("CustomerClueAllocationCtrl", ["$log", "$q", "$timeout", "$scope", "$modalInstance", "host", "customerClueSvc", "multiOfficeDataDic", "loginContext", "aresNotification", function(n, t, i, r, u, f, e, o, s, h) { "use strict"; var c = function() { u.dismiss() },
        l = function() { var n = t.defer(),
                i = s.officeId; return o.loadDic(i, "webPhoneConsultantDic").then(function(t) { r.orProviders = _.filter(t, function(n) { return n.isInactive == !1 && n.show == !0 });
                n.resolve(!0) }), n.promise },
        a = function() { var t = r.newProviders,
                n = v(); if (!n.length) { h.error("请选择员工！"); return } r.allocation.providerIds = n;
            y() },
        v = function() { var n = []; return r.newProviders.forEach(function(t) { n.push(t.id) }), n = _.uniq(n) },
        y = function() { e.allocationClue(r.allocation).success(function(n) { u.close(n) }) };
    (function() { r.cancel = c;
        r.save = a;
        r.allocation = { allocationType: 2, customerClueIds: f.customerClueIds };
        l() })() }]);
managementModule.directive("customerClueTrackEditView", ["$log", "$q", "$timeout", "$modal", "$window", "practiceSvc", function(n, t, i, r, u) { return { replace: !0, templateUrl: "/app/management/dialogs/customer-clue-track-edit-dialog/customer-clue-track-edit-view.html", link: function(n, t) { var r, f, e, i = function(i, u) { var s = t.find("#" + i),
                        o = s.kendoDropDownList({ dataSource: n.systemSettingitems, dataTextField: "itemName", dataValueField: "itemName" }).data("kendoDropDownList");
                    u == "first" ? r = o : u == "next" ? f = o : u == "last" && (e = o) },
                o = function() { i("firstFollow", "first");
                    i("nextFollow", "next");
                    i("lastFollow", "last");
                    s() },
                s = function() { var t = n.customerClue;
                    t.firstFollow && r.value(t.firstFollow);
                    t.nextFollow && f.value(t.nextFollow);
                    t.lastFollow && e.value(t.lastFollow) },
                h = function() { var n = angular.element(u).height(),
                        i = n - 130,
                        r = t.find("#form-info");
                    r.height(i) };
            (function() { n.initData().then(function() { n.editType == "edit" && o();
                    h() }) })() } } }]);
managementModule.controller("CustomerClueTrackEditCtrl", ["$log", "$q", "$timeout", "$scope", "$modalInstance", "host", "customerClueSvc", "loginContext", "patientSvc", "dataDicSvc", function(n, t, i, r, u, f, e, o, s, h) { "use strict"; var a = function() { u.dismiss() },
        v = function(n) { s.getFullPatient(n).then(function(t) { t.data.privateTag ? l(t.data.patientTagUseList, t.data.privateTag.tagStr) : l(t.data.patientTagUseList);
                y(n);
                r.patient = t.data }) },
        y = function(n) { s.getBodyCheck(n, !0).success(function(n) { r.patient.bodycheck = n }) },
        l = function(n, t) { var i = [],
                u = []; if (r.patientTags = [], t && t.length > 0 && (i = p(t)), n && n.length > 0) return h.patientTagDic.loadActive().then(function(t) { _.each(t, function(t) { _.each(n, function(n) { n.tagId === t.id && (t.isCommonTag = !0, u.push(t)) }) });
                r.patientTags = u.concat(i) });
            r.patientTags = i },
        p = function(n) { var t = n.split(","),
                r, i, u; for (t[0] || t.shift(), t[t.length - 1] || t.pop(), r = [], i = 0; i < t.length; i++) u = {}, u.itemName = t[i], r.push(u); return r },
        w = function() { var n = t.defer(),
                i = f.customerClueId; return r.editType = f.type, e.getCustomerClue(i).success(function(t) { r.customerClue = t;
                v(t.patientId);
                n.resolve(!0) }), n.promise },
        b = function() { var n = r.customerClue;
            n.firstFollow = c(n.firstFollow);
            n.nextFollow = c(n.nextFollow);
            n.lastFollow = c(n.lastFollow);
            e.updateCustomerClue(n).success(function(n) { u.close(n) }) },
        c = function(n) { return n == "全部" && (n = null), n };
    (function() { r.systemSettingitems = f.systemSettingitems;
        r.cancel = a;
        r.save = b;
        r.initData = w })() }]);
managementModule.directive("followupAutoRuleEditView", ["$q", "$timeout", "enums", "aresNotification", "dataDicSvc", "followupUtil", "followupSvc", "officeOptionSvc", "$modal", function(n, t, i, r, u, f, e, o, s) { "use strict"; return { restrict: "E", replace: !0, templateUrl: "/app/management/dialogs/followup-auto-rule-edit-dialog/followup-auto-rule-edit-view.html", link: function(h, c) { var y = function() { var n = [];
                    h.savedChargeItemConds.forEach(t => n.push({ condType: t.condType, condValue: t.id }));
                    h.savedChargeCategoryConds.forEach(t => n.push({ condType: t.condType, condValue: t.id }));
                    h.savedTransactioncodeConds.forEach(t => n.push({ condType: t.condType, condValue: t.id }));
                    h.savedApptCategoryConds.forEach(t => n.push({ condType: t.condType, condValue: t.id }));
                    h.checkinTypes.forEach(t => t.forEach(t => { t.checked && n.push({ condType: "apptCheckInType", condValue: t.itemName }) }));
                    (!h.isSendAdviceWhenAutoFollowupEnabled || h.savedTransactioncodeConds.length > 0 || h.savedApptCategoryConds.length > 0) && (h.followupAutoRule.isSendAdvice = !1);
                    h.followupAutoRule.followupRuleConds = n;
                    h.followupAutoRule.category = h.followupRuleTemplate.category;
                    h.followupAutoRule.ruleType = h.followupRuleTemplate.ruleType;
                    h.followupAutoRule.creationMode = h.followupRuleTemplate.creationMode;
                    h.followupAutoRule.timeMode = h.followupRuleTemplate.timeMode;
                    h.followupAutoRule.followupRuleActions = h.followupRuleTemplate.followupRuleActions;
                    f.validateFollowupRule(h.followupAutoRule) && h.saveFollowupAutoRule().then(function() { r.success("保存成功。") }) },
                l = function(t, i) { var r = n.defer(),
                        f = h.followupAutoRule.followupRuleConds,
                        e, u; return f && f.length > 0 ? (e = f.filter(n => n.condType == t), e.length > 0 ? (u = [], i.load().then(function(n) { e.forEach(i => { var r = n.find(n => n.id == i.condValue);
                            r && (t == "transactioncode" ? u.push({ id: r.id, condType: t, itemName: r.name }) : u.push({ id: r.id, condType: t, itemName: r.itemName })) });
                        r.resolve(u) })) : r.resolve([])) : r.resolve([]), r.promise },
                p = function() { t(function() { c.find('[data-toggle="tooltip"]').tooltip() });
                    e.searchFollowupTemplates({ isDisabled: !1, pageIndex: 1, pageSize: 1e5 }).then(function(n) { var r = n.data.items;
                        c.find("#auto-rule-template").kendoDropDownList({ optionLabel: "请选择模板", dataTextField: "ruleName", dataValueField: "id", dataSource: r, select: function(n) { var r = this.dataItem(n.item);
                                r.id ? h.getFollowupTemplateById(r.id).then(function(n) { n.id = 0;
                                    n.ruleType = i.FollowupRuleType.Rule;
                                    n.followupRuleActions.forEach(function(n, t) { n.id = 0;
                                        n.showOrder = t + 1 });
                                    h.followupRuleTemplate = n }) : t(function() { h.followupRuleTemplate = { ruleType: i.FollowupRuleType.Rule, creationMode: i.FollowupCreationMode.AllAtOnce, timeMode: i.FollowupTimeMode.Absolute } }) } }) }) },
                w = function(n, t) {
                    (n === "transactioncode" || n === "apptCategory") && t && t.length > 0 && (h.followupAutoRule.isSendAdvice = !1) },
                b = function() { o.getOfficeOption(o.optionKeys.IsSendAdviceWhenAutoFollowupEnabled).then(function(n) { h.isSendAdviceWhenAutoFollowupEnabled = n }) },
                k = [{ id: 0, name: "按就诊内容" }, { id: 1, name: "按就诊类型" }],
                d = function() { var n = h.followupAutoRule.followupRuleConds,
                        t = [];
                    n && n.length > 0 && (t = n.filter(n => n.condType == "apptCheckInType"));
                    u.systemsettingDic.loadActive().then(function(n) { var r = _.filter(n, function(n) { return n.itemType === "就诊类型" }),
                            u, i; for (_.each(r, function(n) { n.checked = _.some(t, function(t) { return t.condValue == n.itemName }) }), h.editable || (r = _.filter(r, function(n) { return n.checked })), u = [], i = 0; i < r.length; i = i + 4) u.push(r.slice(i, i + 4));
                        console.log(u);
                        h.checkinTypes = u }) },
                g = function() { h.followupAutoRule.isSendAdvice = !1; switch (h.followupAutoRule.ruleSubType) {
                        case i.FollowupRuleSubType.ApptContent:
                            v(); break;
                        case i.FollowupRuleSubType.ApptCheckInType:
                            a(); break;
                        default:
                            a();
                            v() } },
                a = function() { h.savedChargeItemConds = [];
                    h.savedChargeCategoryConds = [];
                    h.savedTransactioncodeConds = [];
                    h.savedApptCategoryConds = [] },
                v = function() { h.checkinTypes.forEach(n => n.forEach(n => n.checked = !1)) },
                nt = function() { s.open({ animation: !0, backdrop: "static", template: "<followup-auto-rule-description-view><\/product-category-select-modal-view>", controller: "FollowupAutoRuleDescriptionCtrl", windowClass: "small-dialog" }) };
            (function() { h.isSendAdviceWhenAutoFollowupEnabled = !1;
                h.onSaveClick = y;
                h.onConditionChange = w;
                h.followupRuleSubTypes = k;
                h.onFollowRuleSubTypeChange = g;
                h.viewRuleDescription = nt;
                b();
                d();
                l("chargeItem", u.chargeItemDic).then(function(n) { h.savedChargeItemConds = n });
                l("chargeCategory", u.chargeCategoryDic).then(function(n) { h.savedChargeCategoryConds = n });
                l("transactioncode", u.transactionCodeDic).then(function(n) { h.savedTransactioncodeConds = n });
                l("apptCategory", u.systemsettingDic).then(function(n) { h.savedApptCategoryConds = n });
                p() })() } } }]);
managementModule.controller("FollowupAutoRuleEditCtrl", ["$modalInstance", "$q", "$scope", "host", "followupSvc", function(n, t, i, r, u) { var f = function() { n.dismiss() },
        e = function() { var r = t.defer(); return u.saveFollowupAutoRule(i.followupAutoRule).success(function() { n.close();
                r.resolve() }), r.promise },
        o = function(n) { var i = t.defer(); return u.getFollowupTemplateById(n).success(function(n) { i.resolve(n) }), i.promise };
    (function() { var t, n; for (i.cancel = f, i.saveFollowupAutoRule = e, i.getFollowupTemplateById = o, i.followupAutoRule = r.followupAutoRule, i.followupAutoRule.isDisable = i.followupAutoRule.ruleName == "重点频繁随访模版" || i.followupAutoRule.ruleName == "多次随访模版" || i.followupAutoRule.ruleName == "两次随访模版" || i.followupAutoRule.ruleName == "诊后默认随访", i.followupAutoRule.isDefaultRule = r.followupAutoRule.ruleName == "诊后默认随访", i.editable = r.editable, t = _.sortBy(r.followupAutoRule.followupRuleActions, "showOrder"), n = 0; n < t.length; n++) t[n].showOrder = n + 1;
        i.followupRuleTemplate = { id: r.followupAutoRule.id, category: r.followupAutoRule.category, ruleType: r.followupAutoRule.ruleType, creationMode: r.followupAutoRule.creationMode, timeMode: r.followupAutoRule.timeMode, followupRuleActions: t } })() }]);
managementModule.directive("followupAutoRuleDescriptionView", ["$modal", "$q", "$timeout", function() { "use strict"; return { restrict: "E", replace: !0, templateUrl: "/app/management/dialogs/followup-auto-rule-edit-dialog/dialog/followup-auto-rule-description-view.html", link: function() {
            (function() {})() } } }]);
managementModule.controller("FollowupAutoRuleDescriptionCtrl", ["$modalInstance", "$q", "$scope", function(n, t, i) { var r = function() { n.dismiss() };
    (function() { i.cancel = r })() }]);
managementModule.directive("followupTemplateEditView", ["$log", "$modal", "$timeout", "aresNotification", "followupUtil", function(n, t, i, r, u) { "use strict"; return { restrict: "E", replace: !0, templateUrl: "/app/management/dialogs/followup-template-edit-dialog/followup-template-edit-view.html", link: function(n) { var t = function() { var t = n.followupTemplate;
                t.ruleName && (t.ruleName = t.ruleName.trim());
                u.validateFollowupRule(t) && n.saveFollowUpTemplate().then(function() { r.success("模板保存成功。") }) };
            (function() { n.onSaveClick = t })() } } }]);
managementModule.controller("FollowupTemplateEditCtrl", ["$modalInstance", "$q", "$scope", "host", "followupSvc", function(n, t, i, r, u) { var f = function() { n.dismiss() },
        e = function() { var r = t.defer(); return u.saveFollowupTemplate(i.followupTemplate).success(function() { n.close();
                r.resolve() }), r.promise };
    (function() { var t, n; for (i.cancel = f, i.saveFollowUpTemplate = e, i.followupTemplate = r.followupTemplate, t = _.sortBy(r.followupTemplate.followupRuleActions, "showOrder"), n = 0; n < t.length; n++) t[n].showOrder = n + 1;
        i.followupTemplate.followupRuleActions = t;
        i.editable = r.editable })() }]);
managementModule.controller("InvoicePackageEditDialogCtrl", ["$log", "$q", "$scope", "$filter", "host", "$timeout", "$modalInstance", "invoiceSvc", "enums", "dataDicSvc", function(n, t, i, r, u, f, e, o, s, h) { "use strict"; var c = r("toLongDateTimeString"),
        l = function(n) { e.close(n) },
        a = function() { var n = i.newPackage.invoiceNoRule; return n.prefix + Ares.getDigitsNumberStr(n.initialValue, n.seqNumberDigits) },
        v = function() { var n = i.newPackage.invoiceNoRule; return n.prefix + Ares.getDigitsNumberStr(n.initialValue, n.seqNumberDigits, i.newPackage.count) },
        y = function() { var n = t.defer(),
                i = [p(), w()]; return t.all(i).then(function() { n.resolve() }), n.promise },
        p = function() { var e = t.defer(),
                n = null,
                u, f, r; return i.invoicePackage ? (n = i.invoicePackage, i.isPublish = n.status === s.InvoicePackageStatus.Published, u = moment(n.validStartTime), r = moment(n.validEndTime), i.validDateRange = r.month() - u.month() + 12 * (r.year() - u.year()), i.validDateRange = i.validDateRange || 3, n.validEndTime = c(n.validEndTime)) : (i.validDateRange = 3, f = Ares.today(), r = moment(f).add(i.validDateRange, "month").toDate(), n = { invoiceNoRule: { prefix: "" }, validStartTime: c(f), validEndTime: c(r) }, i.isPublish = !1), i.newPackage = n, e.resolve(), e.promise },
        w = function() { var n = t.defer(); return i.operators = [{ id: 0, name: "请选择员工" }], h.currentOfficeWorkProviderDic.load().then(function(t) { t = t.filter(function(n) { return n.show && !n.isinactive });
                i.operators = i.operators.concat(t);
                n.resolve() }), n.promise },
        b = function() { var n, t;
            i.invoicePackage || (i.newPackage.count = parseInt(i.newPackage.count), n = i.newPackage.invoiceNoRule, n.seqNumberDigits = n.seqNumberDigits || 8, i.newPackage.invoiceNoRule.initialValue = parseInt(n.initialValue));
            i.newPackage.validEndTime = moment(i.newPackage.validStartTime).add(i.validDateRange, "month").format("YYYY-MM-DD HH:mm:ss");
            t = i.newPackage.id > 0 ? o.updatePackage(i.newPackage) : o.createPackage(i.newPackage);
            t.then(function(n) { var t = n.data;
                l(t) }) };
    (function() { i.getStartNumber = a;
        i.getEndNumber = v;
        i.close = l;
        i.save = b;
        i.title = u.title;
        i.invoicePackage = u.invoicePackage;
        y().then(function() { f(function() { i.initDialogView() }) }) })() }]);
managementModule.directive("invoicePackageEditDialog", ["$log", "$modal", "$timeout", function(n, t, i) { "use strict"; return { restrict: "E", replace: !0, templateUrl: "/app/management/dialogs/invoice-package-edit-dialog/invoice-package-edit-dialog.html", link: function(n, t) { var r = function() { u();
                    i(function() { t.find(".invoice-number-example-content").focus() }, 1e3) },
                u = function() { t.find("#operator").kendoDropDownList({ dataSource: n.operators, dataTextField: "name", dataValueField: "id", filter: "contains", index: 0, value: n.invoicePackage ? n.newPackage.ownerId : 0, select: function(t) { var i = this.dataItem(t.item.index());
                            n.newPackage.ownerId = i.id == 0 ? 0 : i.id } }) };
            (function() { n.initDialogView = r })() } } }]);
managementModule.controller("InvoicePackageTransactionDialogCtrl", ["$log", "$q", "$scope", "$filter", "host", "$timeout", "$modalInstance", "invoiceSvc", function(n, t, i, r, u, f, e, o) { "use strict"; var h = r("toLongDateMMString"),
        c = function(n) { e.close(n) },
        l = function() { return o.getActionOpertors(i.packageId).then(function(n) { f(function() { i.operatorList = [{ name: "全部" }].concat(n.data);
                    i.operatorTypeList = [{ name: "全部", value: "all" }, { name: "打印", value: "1" }, { name: "作废", value: "2" }, ] }, 300) }).then(function() { return s() }) },
        s = function() { var n = t.defer(); return i.searchCriteria.startActionTime = i.timeSpan.startDate, i.searchCriteria.endActionTime = i.timeSpan.endDate ? moment(i.timeSpan.endDate).add(1, "day").format("YYYY-MM-DD") : i.timeSpan.endDate, i.searchCriteria.pageIndex = i.page.index, i.searchCriteria.pageSize = i.page.size, i.searchCriteria.actionType = i.searchCriteria.operatorType, o.getTransactionsBySearchCriteria(i.searchCriteria).then(function(t) { var r = t.data;
                r ? f(function() { i.transactionsPage = r.items;
                    i.transactionsPage.forEach(function(n, t) { a(n, t) }) }, 300) : i.transactionsPage = [];
                i.page.count = r ? r.pageCount : 1;
                i.page.size = r ? r.pageSize : 1;
                i.page.index = r ? r.pageIndex : 1;
                i.page.totalCount = r ? r.totalCount : 0;
                n.resolve() }), n.promise },
        a = function(n) { n.actionTypeStr = y(n.actionType);
            n.actionTimeStr = h(n.recordCreatedTime);
            n.targetTypeStr = p(n.targetType);
            n.operatorName = v(n.operatorId) },
        v = function(n) { var t = _.find(i.operatorList, function(t) { return t.userId == n }); return t ? t.name : "未知" },
        y = function(n) { switch (n) {
                case 1:
                    return "打印";
                case 2:
                    return "作废";
                default:
                    return "未知" } },
        p = function(n) { switch (n) {
                case 1:
                    return "收费单打印";
                default:
                    return "未知" } },
        w = function() { var n = Ares.today();
            i.timeSpan = { startDate: moment(n).startOf("month").toDate(), endDate: moment(n).endOf("month").toDate() };
            i.searchCriteria = { startActionTime: i.timeSpan.startDate, endActionTime: i.timeSpan.endDate, invoicePackageId: i.packageId };
            i.page = { index: 1, size: 15 } };
    (function() { i.packageId = u.packageId;
        i.startNumber = u.startNumber;
        i.searchInvoiceTransactions = s;
        i.close = c;
        w();
        l().then(function() { f(function() { i.initView() }, 500) }) })() }]);
managementModule.directive("invoicePackageTransactionDialog", ["$log", "$modal", "$timeout", function() { "use strict"; return { restrict: "E", replace: !0, templateUrl: "/app/management/dialogs/invoice-package-transaction-dialog/invoice-package-transaction-dialog.html", link: function(n, t) { var i = null,
                r = function() { var u = $(window).height() - 240,
                        n = t.find("#list-body"),
                        r;
                    n.css("height", u);
                    r = { scrollButtons: { enable: !1 }, autoHideScrollbar: !0, scrollInertia: 150, advanced: { updateOnContentResize: !0 } };
                    i == null ? (n.mCustomScrollbar(r), i = n) : i.mCustomScrollbar("update") };
            (function() { n.initView = r })() } } }]);
managementModule.directive("organizationBusinessEditView", ["$log", "$q", "$timeout", "$modal", "dataDicSvc", "orgmanagementSvc", "aresNotification", function(n, t, i, r, u, f) { return { replace: !0, templateUrl: "/app/management/dialogs/organization-business-edit-dialog/organization-business-edit-view.html", link: function(n, t) { var r, s = function() { t.parents(".modal-dialog").css("width", "360px");
                    i(function() { Ares.centerModal(t.closest(".modal-dialog")) }, 50) },
                h = function() { u.currentOfficeInfoDic.load().then(function(i) { var r = t.find("#officeInput").kendoDropDownList({ dataSource: i, filter: "contains", dataTextField: "name", dataValueField: "id", optionLabel: "请选择诊所", value: n.business.officeId || null, change: function(n) { var t = this.dataItem(n.item)[this.options.dataValueField] || null;
                                e(t) }, select: function(t) { n.business.officeId = this.dataItem(t.item)[this.options.dataValueField] || null } }).data("kendoDropDownList");
                        r.enable(!n.business.id) }) },
                e = function(i) { var u = { officeId: i };
                    f.listDepartment(u).success(function(u) { i || (u = []); var f = t.find("#departmentInput");
                        r = f.kendoDropDownList({ dataSource: u, filter: "contains", dataTextField: "name", dataValueField: "id", optionLabel: "请选择科室", value: n.business.departmentId || null, change: function(n) { var t = this.dataItem(n.item)[this.options.dataValueField] || null;
                                o(i, t) }, select: function(t) { n.business.departmentId = this.dataItem(t.item)[this.options.dataValueField] || null } }).data("kendoDropDownList");
                        r.enable(!n.business.id) }) },
                o = function(i, r) { var u = { officeId: i, departmentId: r };
                    f.listJobTitle(u).success(function(i) { var r = t.find("#businessInput").kendoDropDownList({ dataSource: i, filter: "contains", dataTextField: "name", dataValueField: "id", optionLabel: "未指定上级职务", value: n.business.parentId || null, select: function(t) { n.business.parentId = this.dataItem(t.item)[this.options.dataValueField] || null } }).data("kendoDropDownList");
                        r.enable(!n.business.id) }) },
                c = function() { var t = n.business.officeId;
                    h();
                    e(t);
                    o() },
                l = function(t) { var i = t ? t.id : 0;
                    n.business.pictureId = i };
            (function() { n.updateBusinessPicture = l;
                s();
                n.initData().then(function() { c() }) })() } } }]);
managementModule.controller("OrganizationBusinessEditCtrl", ["$log", "$q", "$timeout", "$scope", "$modalInstance", "host", "orgmanagementSvc", "loginContext", "aresNotification", function(n, t, i, r, u, f, e, o, s) { "use strict"; var h = function() { u.dismiss() },
        c = function() { var n = t.defer(),
                i = f.businessId; return i ? e.getJobTitle(i).success(function(t) { r.business = t;
                n.resolve(!0) }) : (r.business = { officeId: o.officeId }, n.resolve(!0)), n.promise },
        l = function() { var n = y(),
                t = f.businessId;
            n && (t ? v() : a()) },
        a = function() { e.addJobTitle(r.business).success(function(n) { u.close(n) }) },
        v = function() { e.updateJobTitle(r.business).success(function(n) { u.close(n) }) },
        y = function() { var n = r.business,
                t; return n.parentId = n.parentId ? n.parentId : 0, t = !0, n.officeId || (s.error("请选择诊所"), t = !1), n.departmentId || (s.error("请选择科室"), t = !1), _.isEmpty(n.name) && (s.error("请输入职务名称"), t = !1), t };
    (function() { r.cancel = h;
        r.save = l;
        r.initData = c })() }]);
managementModule.directive("organizationDepartmentEditView", ["$log", "$q", "$timeout", "$modal", "dataDicSvc", "orgmanagementSvc", "aresNotification", function(n, t, i, r, u, f) { return { replace: !0, templateUrl: "/app/management/dialogs/organization-department-edit-dialog/organization-department-edit-view.html", link: function(n, t) { var e = function() { t.parents(".modal-dialog").css("width", "450px");
                    i(function() { Ares.centerModal(t.closest(".modal-dialog")) }, 50) },
                o = function() { u.currentOfficeInfoDic.load().then(function(i) { var u = t.find("#officeInput").kendoDropDownList({ dataSource: i, filter: "contains", dataTextField: "name", dataValueField: "id", optionLabel: "请选择诊所", value: n.department.officeId || null, change: function(n) { var t = this.dataItem(n.item)[this.options.dataValueField] || null;
                                r(t) }, select: function(t) { n.department.officeId = this.dataItem(t.item)[this.options.dataValueField] || null } }).data("kendoDropDownList");
                        u.enable(!n.department.id) }) },
                r = function(i) { var r = { officeId: i };
                    f.listDepartment(r).success(function(i) { var r = t.find("#departmentInput").kendoDropDownList({ dataSource: i, filter: "contains", dataTextField: "name", dataValueField: "id", optionLabel: "未指定上级", value: n.department.parentId || null, select: function(t) { n.department.parentId = this.dataItem(t.item)[this.options.dataValueField] || null } }).data("kendoDropDownList");
                        r.enable(!n.department.id) }) },
                s = function() { var r = n.department.departmentType;
                    r = r >= 0 ? r : null;
                    kendoDepartmentTypeDropDownList = t.find("#departmentType").kendoDropDownList({ dataSource: [{ name: "行政", value: 1 }, { name: "医疗", value: 2 }], dataTextField: "name", dataValueField: "value", value: r, select: function(t) { var r = this;
                            i(function() { n.department.departmentType = r.dataItem(t.item)[r.options.dataValueField] }) } }).data("kendoDropDownList") },
                h = function() { o();
                    s();
                    r() },
                c = function(t) { var i = t ? t.id : 0;
                    n.department.pictureId = i };
            (function() { n.updateDepartmentPicture = c;
                e();
                n.initData().then(function() { h() }) })() } } }]);
managementModule.controller("OrganizationDepartmentEditCtrl", ["$log", "$q", "$timeout", "$scope", "$modalInstance", "host", "orgmanagementSvc", "aresNotification", function(n, t, i, r, u, f, e, o) { "use strict"; var s = function() { u.dismiss() },
        h = function() { var n = t.defer(),
                i = f.departmentId; return i ? e.getDepartment(i).success(function(t) { r.department = t;
                n.resolve(!0) }) : (r.department = { departmentType: 1 }, n.resolve(!0)), n.promise },
        c = function() { var n = v(),
                t = f.departmentId;
            n && (t ? a() : l()) },
        l = function() { e.addDepartment(r.department).success(function(n) { u.close(n) }) },
        a = function() { e.updateDepartment(r.department).success(function(n) { u.close(n) }) },
        v = function() { var n = r.department,
                t; return n.parentId = n.parentId ? n.parentId : 0, t = !0, n.officeId || (o.error("请选择诊所"), t = !1), _.isEmpty(n.name) && (o.error("请请输入科室名称"), t = !1), t };
    (function() { r.cancel = s;
        r.save = c;
        r.initData = h })() }]);
supplychainModule.directive("organizationProviderJobTitleEditView", ["$log", "$q", "$timeout", "$modal", "dataDicSvc", "orgmanagementSvc", "aresNotification", function(n, t, i) { return { replace: !0, templateUrl: "/app/management/dialogs/organization-provider-job-title-edit-dialog/organization-provider-job-title-edit-view.html", link: function(n, t) { var r = function() { t.parents(".modal-dialog").css("width", "360px");
                    i(function() { Ares.centerModal(t.closest(".modal-dialog")) }, 50) },
                u = function() { t.find("#providerInput").kendoDropDownList({ dataSource: n.providers, dataTextField: "name", dataValueField: "id", optionLabel: "请选择员工", value: null, select: function(t) { n.providerId = this.dataItem(t.item)[this.options.dataValueField] || null } }) },
                f = function() { u() };
            (function() { r();
                n.initData().then(function() { f() }) })() } } }]);
supplychainModule.controller("OrganizationProviderJobTitleEditCtrl", ["$log", "$q", "$timeout", "$scope", "$modalInstance", "host", "orgmanagementSvc", "loginContext", "multiOfficeDataDic", function(n, t, i, r, u, f, e, o, s) { "use strict"; var h = function() { u.close() },
        c = function() { var n = t.defer(); return r.officeId = f.officeId, s.loadDic(r.officeId, "currentOfficeWorkProviderDic").then(function(t) { r.providers = t;
                n.resolve(!0) }), n.promise },
        l = function() { var n = { officeId: r.officeId, providerId: r.providerId, jobTitleId: f.jobTitleId };
            e.addProviderJobTitle(n).success(function(n) { u.close(n) }) };
    (function() { r.cancel = h;
        r.save = l;
        r.initData = c })() }]);
chargeModule.directive("orgchainBaseDataSyncInfoDialogView", ["$log", "$modal", "$timeout", function() { return { restrict: "E", replace: !0, templateUrl: "/app/management/dialogs/orgchain-base-data-sync-info-dialog/orgchain-base-data-sync-info-dialog-view.html", link: function() {
            (function() {})() } } }]);
chargeModule.controller("OrgchainBaseDataSyncInfoDialogCtrl", ["$log", "$q", "$scope", "host", "$timeout", "$modalInstance", function(n, t, i, r, u, f) { "use strict"; var e = function(n) { f.close(n) };
    (function() { i.categoryName = r.categoryName;
        i.distributionList = r.distributionList;
        i.close = e })() }]);
var management;
(function() { "use strict"; var n = function() {
        function n(n) { var t = this;
            this.$timeout = n;
            this.restrict = "E";
            this.templateUrl = "/app/management/dialogs/patient-video-play-dialog/patient-video-play-dialog-view.html";
            this.replace = !0;
            this.link = function(n, i) { n.videoEl = i.find("video")[0];
                i.find("video").bind("contextmenu", function() { return !1 }); var r = function() { n.currentVideo && n.currentVideo.url && (n.videoEl.src = n.currentVideo.url, t.$timeout(function() { n.videoEl.addEventListener("ended", function() { n.play() }) })) };
                (function() { r() })() } } return n.$inject = ["$timeout"], n }();
    managementModule.directive("patientVideoPlayDialogView", Ares.tsDirective(n)) })(management || (management = {}));
var management;
(function() { "use strict"; var n = function() {
        function n(n, t, i, r) { this.$scope = n;
            this.$timeout = t;
            this.$modalInstance = i;
            this.host = r;
            this.videoList = [];
            this.curIdx = 0;
            this.vLen = 0;
            this.isListLoop = !1;
            n.currentVideo = r.video;
            this.videoList = r.videoList;
            this.curIdx = r.index || 0;
            this.vLen = r && r.videoList ? r.videoList.length : 0;
            this.isListLoop = r.loop } return n.prototype.play = function() { var n = this; if (this.curIdx++, this.curIdx >= this.vLen) { if (!this.isListLoop) { console.log("ended play", this.$scope.currentVideo); return } this.curIdx = 0 } this.$scope.currentVideo.hasLoaded || this.cachedVideo(this.$scope.currentVideo);
            this.$timeout(function() { n.$scope.$apply(function() { n.$scope.currentVideo = n.videoList[n.curIdx];
                    n.$scope.videoEl.src = n.$scope.currentVideo.cachedSrc || n.$scope.currentVideo.url;
                    n.$scope.videoEl.load();
                    n.$scope.videoEl.play() }) }, 1e3) }, n.prototype.cachedVideo = function(n) { var t = new XMLHttpRequest;
            t.open("GET", n.url, !0);
            t.responseType = "arraybuffer";
            t.timeout = 1e3;
            t.send();
            t.onload = function() { if (t.status === 200) { var i = new Uint8Array(t.response),
                        r = window.URL.createObjectURL(new Blob([i], { type: "video/mp4" }));
                    n.cachedSrc = r;
                    n.hasLoaded = !0 } };
            t.onerror = function() { console.log("video request was wrong") } }, n.prototype.handleCloseModal = function(n) { n.stopPropagation();
            this.$modalInstance.dismiss() }, n.$inject = ["$scope", "$timeout", "$modalInstance", "host"], n }();
    managementModule.controller("PatientVideoPlayDialogCtrl", Ares.tsController(n)) })(management || (management = {}));
managementModule.directive("performanceNetworkConsultDetailDialogView", ["$log", "$modal", "$timeout", "$window", "gridOptionUtil", function(n, t, i, r, u) { return { restrict: "E", replace: !0, templateUrl: "/app/management/dialogs/performance-network-consult-detail-dialog/performance-network-consult-detail-dialog-view.html", link: function(n, t) { var f, e = function() { var i = t.find("#network-list"),
                        o = i.offset().top,
                        s = r.innerHeight - 200,
                        e;
                    i.html("");
                    e = u.getDefaultGridOption({ data: n.pageData, aggregate: n.aggregate }, n.column);
                    f = i.kendoGrid(e).data("kendoGrid") },
                o = function() { f && f.saveAsExcel() };
            (function() { n.exportExcel = o;
                n.$watch("pageData", function() { e() });
                i(function() { Ares.centerModal(t.closest(".modal-dialog")) }, 5) })() } } }]);
managementModule.controller("PerformanceNetworkConsultDetailDialogCtrl", ["$log", "$q", "$scope", "host", "$timeout", "$modalInstance", function(n, t, i, r, u, f) { "use strict"; var e = function() { f.close("cencel") },
        o = function() { switch (r.showType) {
                case 0:
                    i.title = "新建患者列表"; break;
                case 1:
                    i.title = "新建待预约列表"; break;
                case 2:
                    i.title = "新建预约列表"; break;
                case 5:
                    i.title = "消费金额列表" } };
    (function() { o();
        i.column = r.column;
        i.pageData = r.pageData;
        i.aggregate = r.aggregate;
        i.cancel = e })() }]);
managementModule.directive("sceneConsultListDialogView", ["$log", "$timeout", "$window", "aresDialog", function(n, t, i, r) { "use strict"; return { restrict: "E", replace: !0, templateUrl: "/app/management/dialogs/scene-consult-list-dialog/scene-consult-list-dialog-view.html", link: function(n, i) { var u = function() { var t = i.find("#taskNotes").val(); if (!t) { r.info("提示", "忽略咨询任务需填写备注！"); return } if (t && t.length > 500) { r.info("提示", "内容长度不允许超过500！"); return } n.save(t) };
            (function() { n.onSave = u;
                t(function() { Ares.centerModal(i.closest(".modal-dialog")) }, 5) })() } } }]);
managementModule.controller("sceneConsultListDialogCtrl", ["$log", "$timeout", "$q", "$scope", "$modalInstance", "host", "commonTaskSvc", function(n, t, i, r, u, f, e) { "use strict"; var o = function(n) { var r = { taskId: f.taskId, notes: n },
                t = i.defer(); return e.ignore(r).success(function(n) { t.resolve(n);
                u.close(n) }), t.promise },
        s = function() { u.close() };
    (function() { r.cancel = s;
        r.save = o })() }]);
managementModule.factory("managementDialogUtil", ["$log", "$q", "$modal", "enums", "aresModalShelf", function(n, t, i, r, u) { "use strict"; var f = function(n, t = true) { var i = n.id > 0,
                r = u.open({ title: i ? "编辑随访节点模板" : "新建随访节点模板", titleIconClass: i ? "iconfont icon-bianji" : "iconfont icon-addition", template: "<followup-template-edit-view><\/followup-template-edit-view>", controller: "FollowupTemplateEditCtrl", resolve: { host: function() { return { followupTemplate: angular.copy(n), editable: t } } }, confirmClose: t, needActive: !0 }); return r.result },
        e = function(n) { var t = i.open({ animation: !0, backdrop: "static", template: "<system-setting-item-edit><\/system-setting-item-edit>", controller: "SystemSettingItemEditCtrl", resolve: { host: function() { return { itemType: n } }, boxTitle: function() { return "" } } }); return t.result },
        o = function(n, t = true) { var i = n.id > 0,
                r, f; return r = i ? t ? "编辑自动随访规则" : "查看自动随访规则" : "新建自动随访规则", f = u.open({ title: r, titleIconClass: i ? "iconfont icon-bianji" : "iconfont icon-addition", template: "<followup-auto-rule-edit-view><\/followup-auto-rule-edit-view>", controller: "FollowupAutoRuleEditCtrl", resolve: { host: function() { return { followupAutoRule: angular.copy(n), editable: t } } }, confirmClose: t, needActive: !0 }), f.result },
        s = function(n) { if (Ares.ensureNotDuplicated("openTransactionHisotryDialog", 500)) var t = i.open({ animation: !0, backdrop: "static", template: "<membership-point-history-view><\/membership-point-history-view>", controller: "membershipPointHistoryCtrl", size: "lg", windowClass: "membership-transaction-history-dialog", resolve: { host: function() { return { patientId: n } } } }) },
        h = function(n, t) { if (Ares.ensureNotDuplicated("openRefereeDialog", 500)) var r = i.open({ animation: !0, backdrop: "static", template: "<patient-referee-detail-view><\/patient-referee-detail-view>", controller: "PatientRefereeDetailCtrl", size: "lg", resolve: { host: function() { return { patient: n, officeIds: t } } } }) }; return { openEditFollowupTemplateDialog: f, openSystemSettingItemEdit: e, openEditFollowupAutoRuleDialog: o, openTransactionHisotryDialog: s, openRefereeDialog: h } }]);
managementModule.directive("apptPerformanceView", ["$log", "$timeout", "$filter", "$window", "appNav", "enums", "practiceSvc", "gridOptionUtil", function(n, t, i, r, u, f, e, o) { "use strict"; return { restrict: "E", replace: !0, controller: "ApptPerformanceCtrl", templateUrl: "/app/management/views/appt-performance-view.html", scope: { officeId: "=" }, link: function(n, t) { var u, i, f = function() { var f = t.find(".control-panel"),
                        s = r.innerHeight - f.offset().top - f.height() - 25,
                        e;
                    u = t.find("#apptPerformanceList");
                    e = o.getDefaultGridOption({ data: n.pageData }, [{ field: "createdUser", menu: !1, title: "创建人", width: "120px" }, { field: "checkedInCount", title: "实际到诊", width: "300px" }, { field: "cancelledCount", title: "已取消", width: "120px" }, { field: "failedCount", title: "失约", width: "120px" }, ], s);
                    i = u.kendoGrid(e).data("kendoGrid") },
                s = function() { i && i.dataSource.data(n.pageData) },
                h = function() { e.getHasUserAccount().success(function(i) { var r = i,
                            u;
                        r.splice(0, 0, { id: -1, name: "全部" });
                        u = t.find("#createInput");
                        u.kendoDropDownList({ dataSource: r, placeholder: "", dataTextField: "name", dataValueField: "id", select: function(t) { var i = this.dataItem(t.item.index());
                                n.createId = i.id } }) }) };
            n.exportExcel = function() { i && i.saveAsExcel() },
                function() { h();
                    n.$watch("pageData", function() { i ? s() : f() }) }() } } }]);
managementModule.directive("apptTransferredView", ["$log", "$timeout", "$filter", "$window", "gridOptionUtil", "practiceSvc", "dataDicSvc", "reportUtil", function(n, t, i, r, u, f, e, o) { "use strict"; return { restrict: "E", replace: !0, controller: "ApptTransferredCtrl", templateUrl: "/app/management/views/appt-transferred-view.html", scope: { officeId: "=" }, link: function(n, t) { var a = Ares.kendoGridUtil(r, n),
                i = null,
                f = function() { var n = t.find(".control-panel"),
                        e = r.innerHeight - n.offset().top - n.height() - 15,
                        o = t.find("#apptPerformanceList"),
                        f = u.getDefaultGridOption(u.dataSource(s), [{ field: "startTimeStr", title: "就诊日期", width: "120px" }, { field: "checkinType", title: "就诊类型", width: "100px" }, { field: "privateId", title: "病历号", width: "80px" }, { field: "name", title: "患者姓名", width: "80px" }, { field: "sexStr", title: "性别", width: "80px" }, { field: "mobile", title: "手机号", width: "100px" }, { field: "ageStr", title: "年龄", width: "80px" }, { field: "fromDoctorIdStr", title: "转出医生", width: "80px" }, { field: "fromDoctorDepartment", title: "转出科室", width: "80px" }, { field: "toDoctorIdStr", title: "转入医生", width: "80px" }, { field: "toDoctorDepartment", title: "转入科室", width: "80px" }, { field: "totalPlanPrice", title: "消费金额", width: "80px", format: "{0:n}" }, ], e);
                    f.pageable = u.pageable;
                    i = o.kendoGrid(f).data("kendoGrid") },
                s = function(t) { n.searchCriteria.pageIndex = t.data.page;
                    n.searchCriteria.pageSize = t.data.pageSize;
                    o.checkReportDayLimited(n.searchCriteria.startDate, n.searchCriteria.endDate).then(function() { n.search().then(function(i) { n.gridData = i;
                            t.success(i) }) }, function() { t.success(n.gridData) }) },
                h = function() { e.doctorDic.loadActive().then(function(i) { var r = i,
                            u, f;
                        r.splice(0, 0, { id: -1, name: "全部" });
                        u = t.find("#fromDoctorInput");
                        f = t.find("#toDoctorInput");
                        u.kendoDropDownList({ dataSource: r, placeholder: "", dataTextField: "name", dataValueField: "id", select: function(t) { var i = this.dataItem(t.item.index());
                                n.fromDoctorId = i.id } });
                        f.kendoDropDownList({ dataSource: r, placeholder: "", dataTextField: "name", dataValueField: "id", select: function(t) { var i = this.dataItem(t.item.index());
                                n.toDoctorId = i.id } }) }) },
                c = function() { e.departmentDic.loadActive().then(function(i) { var r = i,
                            u, f;
                        r.splice(0, 0, { itemName: "全部" });
                        u = t.find("#fromDoctorDepartmentInput");
                        f = t.find("#toDoctorDepartmentInput");
                        u.kendoDropDownList({ dataSource: r, placeholder: "", dataTextField: "itemName", dataValueField: "itemName", select: function(t) { var i = this.dataItem(t.item.index());
                                n.fromDoctorDepartment = i.itemName } });
                        f.kendoDropDownList({ dataSource: r, placeholder: "", dataTextField: "itemName", dataValueField: "itemName", select: function(t) { var i = this.dataItem(t.item.index());
                                n.toDoctorDepartment = i.itemName } }) }) },
                l = function() { if (i) { var n = t.find(".k-textbox").val() || 1;
                        i.dataSource.page(n) } else f() };
            (function() { n.refreshGrid = l;
                h();
                c();
                f() })() } } }]);
managementModule.directive("attendanceRulesettingDialog", ["$log", "$filter", function() { "use strict"; return { replace: !0, templateUrl: "/app/management/views/attendance-rulesetting-dialog.html", link: function(n) {
            (function() { $("#palette").kendoColorPicker({ columns: 2, tileSize: { width: 50, height: 30 }, palette: ["#FFD9D9", "#FFC2C2", "#FFAAAA", "#FF7C7C", "#FFE1BE", "#FFCD93", "#FFBF75", "#FFAF51", "#ACFDCE", "#62EC9B", "#A8F4E3", "#62E3C6", "#BEE3FF", "#8DCEFF", "#E5E2FF", "#FFF0A3", "#FFE663", "#E7FFB3", "#D7FF81"], change: function(t) { n.currentRuleDetail && (n.currentRuleDetail.scheduleColor = t.value) } }) })() } } }]);
managementModule.directive("attendanceRulesettingView", ["$log", "$modal", "$filter", "practiceSvc", "aresDialog", "permissionProvider", function(n, t, i, r, u) { "use strict"; return { restrict: "E", replace: !0, controller: "AttendanceRulesettingCtrl", templateUrl: "/app/management/views/attendance-rulesetting-view.html", scope: { officeId: "=" }, link: function(n, t) { var f = !1,
                i = function() { r.listScheduleRulesDetail("ATTEND").success(function(t) { n.ruleDetailList = t }) },
                e = function() { if (!n.isCreateRule) { var t = $("#ruleDetailList").data("kendoGrid");
                        t.cancelChanges();
                        t.addRow();
                        n.isCreateRule = !0 } },
                o = function() { var i = { "class": "table-header-cell", style: "text-align: center; font-weight: bolder" },
                        r, u;
                    n.ruleDetailList && (f = !0, r = function(t) { var r, u, f, i; if (t.is("[name=name]")) { if (r = t.val(), r == "") return t.attr("data-nameValidation-msg", "状态不能为空"), !1; if (n.ruleDetailList)
                                for (u = $(t).closest("tr"), f = $("#ruleDetailList").data("kendoGrid").dataItem(u), i = 0; i < n.ruleDetailList.length; ++i)
                                    if (n.ruleDetailList[i].name == r && n.ruleDetailList[i].id != f.id) return t.attr("data-nameValidation-msg", "名称已被使用，请改名"), !1 } return !0 }, u = t.find("#ruleDetailList"), u.kendoGrid({ dataSource: { data: n.ruleDetailList, schema: { model: { id: "id", fields: { id: { defaultValue: 0 }, name: { validation: { nameValidation: r } }, scheduleColor: { validation: { required: !0 }, defaultValue: "#FFD9D9" } } } } }, scrollable: !1, selectable: "single", editable: { mode: "inline", createAt: "bottom" }, columns: [{ field: "name", title: "状态", width: "150px", headerAttributes: i }, { field: "scheduleColor", title: "标示颜色", width: "80px", headerAttributes: i, attributes: { style: "background-color: #=scheduleColor#;" }, template: "", editor: function(n, t) { $(n).css("background-color", "inherit"); var i = $('<input name="' + t.field + '" type="color" />');
                                i.appendTo($(n));
                                i.kendoColorPicker({ tileSize: 32, palette: ["#FFD9D9", "#FFC2C2", "#FFAAAA", "#FF7C7C", "#FFE1BE", "#FFCD93", "#FFBF75", "#FFAF51", "#ACFDCE", "#62EC9B", "#A8F4E3", "#62E3C6", "#BEE3FF", "#8DCEFF", "#E5E2FF", "#FFF0A3", "#FFE663", "#E7FFB3", "#D7FF81"] });
                                $(n).find(".k-selected-color").css({ width: "100%", height: "2.25em" }) } }, { command: [{ name: "编辑", text: "编辑", click: n.editDetail, className: "fa fa-edit" }, { name: "更新", text: "更新", click: n.updateDetail, className: "fa fa-check hide" }, { name: "取消", text: "取消", click: n.cancelEdit, className: "fa fa-close hide" }, { name: "删除", text: "删除", click: n.deleteDetail, className: "fa fa-trash-o" }], title: "", width: "120px" }], edit: function(n) { n.container.find(".k-grid-编辑,.k-grid-删除").addClass("hide");
                            n.container.find(".k-grid-更新,.k-grid-取消").removeClass("hide") } })) };
            n.editDetail = function(t) { var i, r, u;
                (t.preventDefault(), n.isCreateRule = !1, i = $(t.currentTarget).closest("tr"), r = this.dataItem(i), r && r.id) && (u = $("#ruleDetailList").data("kendoGrid"), u.editRow(i)) };
            n.updateDetail = function(t) { var f;
                t.preventDefault(); var e = $(t.currentTarget).closest("tr"),
                    u = this.dataItem(e),
                    o = e.data("kendoValidator");
                o.validate() && (f = { id: u.id, name: u.name, weekDayType: "AllWeekDays", startTime: "08:00", endTime: "18:00", scheduleColor: u.scheduleColor, status: "ATTEND" }, n.isCreateRule ? r.createScheduleRuleDetail(f).success(function() { n.showNotification("保存成功！");
                    n.isCreateRule = !1;
                    i() }) : r.updateScheduleRuleDetail(f).success(function() { n.showNotification("保存成功！");
                    i() })) };
            n.cancelEdit = function(t) { t.preventDefault(); var i = $("#ruleDetailList").data("kendoGrid");
                i.cancelChanges();
                n.isCreateRule = !1 };
            n.deleteDetail = function(n) { n.preventDefault(); var t = this.dataItem($(n.currentTarget).closest("tr"));
                    t && t.id && u.confirm("删除", "如果删除班次规则，已排班记录均会被删除，确认删除？").then(function() { r.deleteScheduleRuleDetail(t.id).success(function() { i() }) }) },
                function() { n.createRuleDetail = e;
                    i();
                    n.$watch("ruleDetailList", function() { if (f) { var t = $("#ruleDetailList").data("kendoGrid");
                            t.dataSource.data(n.ruleDetailList) } else o() }) }() } } }]);
managementModule.directive("attendanceStaffView", ["$log", "$modal", "$filter", "practiceSvc", "dataDicSvc", "aresDialog", "permissionProvider", function(n, t, i, r) { "use strict"; return { restrict: "E", replace: !0, controller: "AttendanceStaffCtrl", templateUrl: "/app/management/views/attendance-staff-view.html", scope: { officeId: "=" }, link: function(n, t) { var i = !1,
                u;
            n.selectedColIndex = -1;
            n.selectedRowIndex = -1;
            n.startDate = moment(Ares.today()).startOf("month");
            n.endDate = moment(Ares.today()).endOf("month");
            n.ruleDetailList = {};
            u = function() { r.listScheduleRulesDetail("ATTEND").success(function(t) { n.ruleDetailList = t }) };
            n.weekDays = [{ itemName: "星期一", itemValue: "1" }, { itemName: "星期二", itemValue: "2" }, { itemName: "星期三", itemValue: "3" }, { itemName: "星期四", itemValue: "4" }, { itemName: "星期五", itemValue: "5" }, { itemName: "星期六", itemValue: "6" }, { itemName: "星期日", itemValue: "7" }]; var f = function(t) { var i; if (!(n.selectedRowIndex < 0) && !(n.selectedColIndex < 1) && n.doctorScheduleList) { var u = n.doctorScheduleList[n.selectedRowIndex],
                            o = "column" + (n.selectedColIndex - 1),
                            e = "idcolumn" + (n.selectedColIndex - 1),
                            f = n.doctorList[n.selectedColIndex - 1];
                        u[e] == 0 ? (i = {}, i.id = 0, i.providerName = f.name, i.providerId = f.id, i.status = t.name, i.applyDate = moment(u.scheduleDate).format("YYYY-MM-DD HH:mm"), i.scheduleRuleDetailId = t.id, r.createAttendance(i).success(function(t) { u[o] = t.status;
                            u[e] = t.id; var i = $("#scheduleList").data("kendoGrid");
                            i.dataSource.data(n.doctorScheduleList);
                            i.refresh() })) : (i = {}, i.id = u[e], i.providerName = f.name, i.providerId = f.id, i.status = t.name, i.applyDate = moment(u.scheduleDate).format("YYYY-MM-DD HH:mm"), i.scheduleRuleDetailId = t.id, r.updateAttendance(i).success(function() { u[o] = t.name; var i = $("#scheduleList").data("kendoGrid");
                            i.dataSource.data(n.doctorScheduleList);
                            i.refresh() })) } },
                e = function() { if (!(n.selectedRowIndex < 0) && !(n.selectedColIndex < 1) && n.doctorScheduleList) { var t = n.doctorScheduleList[n.selectedRowIndex],
                            u = "column" + (n.selectedColIndex - 1),
                            i = "idcolumn" + (n.selectedColIndex - 1);
                        t[i] != 0 && r.deleteAttendance(t[i]).success(function() { t[u] = "";
                            t[i] = 0; var r = $("#scheduleList").data("kendoGrid");
                            r.dataSource.data(n.doctorScheduleList);
                            r.refresh() }) } },
                o = function() { var n = $("#scheduleList").data("kendoGrid");
                    n && n.saveAsExcel() },
                s = function() { var r, f, u; if (n.doctorScheduleList) { i = !0;
                        r = t.find("#scheduleList");
                        f = $(window).height() - 180;
                        r.kendoGrid({ dataSource: { data: n.doctorScheduleList }, height: f, scrollable: !0, selectable: "cell", columns: n.gridColumns, dataBound: function(t) { for (var u, f, i, s, h, r, c, l = t, a = t.sender.columns, o = t.sender.tbody.children(), e = 0; e < o.length; e++) { for (u = $(o[e]), f = t.sender.dataItem(u), i = 0; i < n.doctorList.length; ++i)
                                        for (s = "column" + i, h = u.children().eq(i + 1), r = 0; r < n.ruleDetailList.length; ++r) n.ruleDetailList[r].name == f[s] && h.css("background-color", n.ruleDetailList[r].scheduleColor);
                                    (f.scheduleDateStr.indexOf("星期六") >= 0 || f.scheduleDateStr.indexOf("星期日") >= 0) && (c = u.children().eq(0), c.css("color", "#FF0000")) } } });
                        u = r.data("kendoGrid");
                        $(u.tbody).on("click", "td", function() { var t = $(this).closest("tr");
                            n.selectedRowIndex = $("tr", u.tbody).index(t);
                            n.selectedColIndex = $("td", t).index(this) }) } };
            n.getWeekSchedule = function() { var t = { startDate: moment(n.startDate).format("YYYY-MM-DD HH:mm"), endDate: moment(n.endDate).format("YYYY-MM-DD HH:mm") };
                    r.getAttendances(t).success(function(t) { var f, e, r, i, l, o, s;
                        n.doctorScheduleList = []; for (var a = n.startDate.month(), u = n.startDate, i = 0; u.month() == a;) { for (f = moment(u).day() - 1, f < 0 && (f = f + 7), e = { scheduleDate: moment(u).format("YYYY-MM-DD"), scheduleDateStr: moment(u).format("YYYY-MM-DD") + "   " + n.weekDays[f].itemName }, r = 0; r < n.doctorList.length; ++r) o = "column" + r, s = "idcolumn" + r, e[o] = "", e[s] = 0;
                            n.doctorScheduleList.push(e);
                            i = i + 1;
                            u = moment(n.startDate).add(i, "d") } for (r = 0; r < t.length; ++r) { var h = t[r],
                                v = moment(h.applyDate).date(),
                                c = n.doctorScheduleList[v - 1]; for (i = 0; i < n.doctorList.length; ++i)
                                if (l = n.doctorList[i], l.id == h.providerId) { o = "column" + i;
                                    s = "idcolumn" + i;
                                    c[o] = h.status;
                                    c[s] = h.id; break } } }) },
                function() { u();
                    n.setRuleDetail = f;
                    n.removeRuleDetail = e;
                    n.exportExcel = o;
                    $("#monthpicker").kendoDatePicker({ start: "year", depth: "year", format: "MMMM yyyy", value: new Date, change: function() { var t = this.value();
                            n.startDate = moment(t).startOf("month");
                            n.endDate = moment(t).endOf("month");
                            n.getWeekSchedule() } });
                    n.gridColumns = [{ field: "scheduleDateStr", title: "日期", width: "150px", headerAttributes: { style: "text-align: center; font-size: 14px; font-weight: bolder;" } }];
                    r.listProviders().success(function(t) { var i, r; for (n.doctorList = [], i = 0; i < t.length; ++i)
                            if (t[i].show == !1) continue;
                            else n.doctorList.push(t[i]); for (i = 0; i < n.doctorList.length; ++i) r = "column" + i, n.gridColumns.push({ field: r, title: n.doctorList[i].name, width: "60px", headerAttributes: { style: "text-align: center; font-size: 14px; font-weight: bolder;" } });
                        n.getWeekSchedule() });
                    n.$watch("doctorScheduleList", function() { if (i) { var t = $("#scheduleList").data("kendoGrid");
                            t.dataSource.data(n.doctorScheduleList) } else s() }) }() } } }]);
managementModule.directive("chargeDeductionView", ["$q", "$log", "$timeout", "$window", "appNav", "aresDialog", "aresNotification", "reportSvc", "providerSvc", "dataDicSvc", "gridOptionUtil", "reportUtil", "$modal", "sessionCache", "localCache", "patientUtil", "enums", "loginContext", "practiceSvc", "formatUtil", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y, p, w, b, k, d) { "use strict"; return { restrict: "AE", replace: !0, templateUrl: "/app/management/views/charge-deduction-view.html", scope: { officeId: "=" }, link: function(t, u) {
            function st() { for (var n = [{ field: "deductionCode", title: "划扣编号", width: "120px", hidden: f("deductionCode") }, { field: "recordCreatedTimeStr", title: "开单日期", width: "180px", hidden: f("recordCreatedTime") }, { field: "payDateTimeStr", title: "首次收费时间", width: "180px", hidden: f("payDateTimeStr") }, { field: "privateId", title: "病例号", width: "110px", hidden: f("privateId") }, { field: "patientName", title: "患者姓名", width: "110px", hidden: f("patientName") }, { field: "gender", title: "性别", width: "80px", hidden: f("gender") }, { field: "age", title: "年龄", width: "80px", hidden: f("age") }, { field: "patientTagStr", title: "患者标签", template: rt.patientTagTemplate, width: "150px", hidden: f("patientTag") }, { field: "createOfficeName", title: "开单诊所", width: "150px", hidden: f("createOfficeName") }, { field: "consultantName", title: "咨询师", width: "100px", hidden: f("consultantName") }, { field: "chargeItemSuperCatagory", title: "收费大类", width: "120px", hidden: f("chargeItemSuperCatagory") }, { field: "chargeItemCatagory", title: "收费小类", width: "120px", hidden: f("chargeItemCatagory") }, { field: "chargeItemName", title: "项目名称", width: "120px", hidden: f("chargeItemName") }, { field: "stepName", title: "治疗步骤", width: "120px", hidden: f("stepName") }, { field: "detailTotalPrice", title: "原价", width: "120px", template: "#= Ares.FormatMoney(detailTotalPrice) #", hidden: f("detailTotalPrice"), aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }, { field: "discountPrice", title: "折扣金额", width: "120px", template: "#= Ares.FormatMoney(discountPrice) #", hidden: f("discountPrice"), aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }, { field: "discount", title: "折扣率", width: "120px", template: '#= Ares.FormatMoney(discount) + "%" #', hidden: f("discount") }, { field: "planPrice", title: "应收", width: "120px", template: "#= Ares.FormatMoney(planPrice) #", hidden: f("planPrice"), aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }, { field: "actualPrice", title: "实收", width: "120px", template: "#= Ares.FormatMoney(actualPrice) #", hidden: f("actualPrice"), aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }, { field: "detailOverdue", title: "欠费", format: "{0:n}", width: "160px", hidden: f("detailOverdue"), aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }, { field: "revenue", title: "确认营收", width: "120px", template: "#= Ares.FormatMoney(revenue) #", hidden: f("revenue"), aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }, { field: "performance", title: "绩效收入", width: "150px", template: "#= Ares.FormatMoney(performance) #", hidden: f("performance"), aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }, { field: "stepIndex", title: "执行次数", width: "120px", hidden: f("stepIndex") }, { field: "deductionStepState", title: "状态", width: "80px", hidden: f("deductionStepState") }, { field: "executionOfficeName", title: "划扣诊所", width: "150px", hidden: f("executionOfficeName") }, { field: "executionTimeStr", title: "划扣时间", width: "180px", hidden: f("executionTime") }, { field: "doctorName", title: "医生", width: "100px", hidden: f("doctorName") }, { field: "nurseName", title: "护士", width: "100px", hidden: f("nurseName") }, { field: "extraProviderName", title: "其他", width: "100px", hidden: f("extraProviderName") }, { field: "manHourCount", title: "所耗工时", width: "100px", hidden: f("manHourCount") }], i = 0; i < t.gridColumns.length; i++) n.push(t.gridColumns[i]); return n.push({ field: "discountPercent", title: "优惠比例", width: "120px", template: '#= Ares.FormatMoney(discountPercent) + "%" #', hidden: f("discountPercent") }), n.push({ field: "discountPriceSum", title: "优惠总额", format: "{0:n}", width: "150px", template: "#= Ares.FormatMoney(discountPriceSum) #", hidden: f("discountPriceSum"), aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }), n.push({ field: "itemDiscountPrice", title: "优惠-手动单项折扣", format: "{0:n}", width: "180px", template: "#= Ares.FormatMoney(itemDiscountPrice) #", hidden: f("itemDiscountPrice"), aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }), n.push({ field: "orderDiscountPrice", title: "优惠-手动整单折扣", format: "{0:n}", width: "180px", template: "#= Ares.FormatMoney(orderDiscountPrice) #", hidden: f("orderDiscountPrice"), aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }), n.push({ field: "giftCertificatePrice", title: "优惠-券", format: "{0:n}", width: "130px", template: "#= Ares.FormatMoney(giftCertificatePrice) #", hidden: f("giftCertificatePrice"), aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }), n.push({ field: "membershipPrice", title: "优惠-会员卡", format: "{0:n}", width: "130px", template: "#= Ares.FormatMoney(membershipPrice) #", hidden: f("membershipPrice"), aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }), n } var rt = Ares.kendoGridUtil(r, t),
                ut = !1,
                v, e, s = [],
                ft = ["deductionCode", "chargeItemSuperCatagory", "chargeItemCatagory", "performance", "discountPercent", "orderDiscountPrice", "itemDiscountPrice", "giftCertificatePrice", "membershipPrice", "discountPriceSum", "manHourCount"],
                nt = y.getCache(y.keys.ChargeDeductionColumnHide),
                et = function() { var n = $(window).height(),
                        t = 130 + u.find("#divCondition").height(),
                        i = n - t,
                        r = i - 81; return Math.max(5, parseInt(r / 40)) },
                f = function(n) { return s.indexOf(n) >= 0 },
                ot = function() { var n = nt.loadObject();
                    s = n instanceof Array ? n : ft },
                it = function() { var n = l.getDefaultTimeSpan(!0);
                    v = { startDate: n.startTime, endDate: moment(n.endTime).subtract(1, "s").format("YYYY-MM-DD HH:mm") };
                    t.timeSpan = _.clone(v) };
            t.radioCharge = function(n) { if (n) it();
                else { var i = Ares.today(),
                        r = moment(i).startOf("month").format("YYYY-MM-DD"),
                        u = moment(i).startOf("month").add(1, "month").add(-1, "days").format("YYYY-MM-DD");
                    t.timeSpan = { startDate: r, endDate: u } } }; var tt = null,
                ht = function() { var n = u.find("#chargeDeductionReportList"),
                        i = n.offset().top,
                        o = r.innerHeight - i - 10;
                    tt = angular.copy(st());
                    tt.forEach(function(n) { n.hidden = f(n.field) });
                    e = n.kendoGrid({ excel: { allPages: !0 }, dataSource: { data: t.pageData, aggregate: t.aggregate }, pageable: c.getPageable(t.pageSize), scrollable: !0, columnMenu: !0, height: o, sortable: !0, resizable: !0, reorderable: !0, selectable: "single", model: { id: "id" }, columns: tt, columnShow: function(n) { s = _.without(s, n.column.field);
                            nt.saveObject(s);
                            Ares.DockGridColMenuPos(n.sender) }, columnHide: function(n) { s.push(n.column.field);
                            nt.saveObject(s);
                            Ares.DockGridColMenuPos(n.sender) }, columnReorder: function(n) { Ares.DockGridColMenuPos(n.sender) }, dataBound: function(n) { Ares.DockGridColMenuPos(n.sender) } }).data("kendoGrid") },
                g = function() { lt().then(function(n) { t.pageData = n;
                        vt(t.pageData);
                        ct(t.pageData); var i = u.find("#chargeDeductionReportList");
                        i.empty();
                        ht() }) },
                ct = function(n) { angular.forEach(n, function(n) { if (n.patientTags && n.patientTags.tags) { var t = "";
                            angular.forEach(n.patientTags.tags, function(n) { t = t + n.itemName + "," });
                            t && (t = t.substring(0, t.length - 1));
                            n.patientTagStr = t } }) },
                lt = function() { var r = n.defer(),
                        i = bt(); return l.checkReportDayLimited(i.startTime, i.endTime).then(function() { return o.getChargeDeductionList(i).success(function(n) { at(n);
                            t.pageData = n;
                            r.resolve(n) }) }), r.promise },
                at = function(n) { d.formatList(n, { payDateTime: "longDateTime" }) },
                vt = function(n) { var u, i, r; for (t.payTypes = [], u = 0; u < n.length; u++)
                        if (i = n[u], i.recordCreatedTimeStr = moment(i.recordCreatedTime).format("YYYY-MM-DD HH:mm:ss"), i.executionTimeStr = i.executionTime ? moment(i.executionTime).format("YYYY-MM-DD HH:mm:ss") : "", i.payTypeAmounts)
                            for (r = 0; r < i.payTypeAmounts.length; r++) t.payTypes.push(i.payTypeAmounts[r].payType), i[i.payTypeAmounts[r].payType] ? i[i.payTypeAmounts[r].payType] += i.payTypeAmounts[r].actualPrice : i[i.payTypeAmounts[r].payType] = i.payTypeAmounts[r].actualPrice;
                    yt(n) },
                yt = function(n) { var f = [],
                        s, o, h, i, r, e, u; for (t.gridColumns = [], t.aggregate = [], t.aggregate.push({ field: "detailTotalPrice", aggregate: "sum" }, { field: "discountPrice", aggregate: "sum" }, { field: "planPrice", aggregate: "sum" }, { field: "actualPrice", aggregate: "sum" }, { field: "detailOverdue", aggregate: "sum" }, { field: "revenue", aggregate: "sum" }, { field: "performance", aggregate: "sum" }, { field: "discountPriceSum", aggregate: "sum" }, { field: "orderDiscountPrice", aggregate: "sum" }, { field: "itemDiscountPrice", aggregate: "sum" }, { field: "giftCertificatePrice", aggregate: "sum" }, { field: "membershipPrice", aggregate: "sum" }), s = 1, r = 0; r < t.payTypes.length; ++r) { for (o = t.payTypes[r], h = !1, i = 0; i < f.length; i++)
                            if (f[i].type == o) { h = !0; break } h == !1 && o != null && o !== "" && (f.push({ index: "p" + s, type: o }), s++) } for (i = 0; i < f.length; i++) { for (r = 0; r < n.length; r++) e = n[r], u = f[i], e[u.index] || (e[u.index] = 0), e[u.type] && (e[u.index] = e[u.type]);
                        t.gridColumns.push({ field: u.index, title: u.type, width: "100px", format: "{0:n}", aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" });
                        t.aggregate.push({ field: f[i].index, aggregate: "sum" }) } },
                pt = function() { e && (ut = !1, g()) },
                wt = function() { e ? (e.dataSource.page() != 1 && e.dataSource.page(1), g()) : g() },
                bt = function() { var u = t.timeSpan.startDate || v.startDate,
                        f = t.timeSpan.endDate || v.endDate,
                        e = ni(),
                        n = $("#statusInput").data("kendoMultiSelect").value(),
                        i, r; return n = n && n.length > 0 ? n.join(",") : -1, i = "-1", t.chargeItems.length > 0 && t.chargeItemNames !== "全部" && (r = _.pluck(t.chargeItems, "id"), i = r.join()), t.minDiscount = t.minDiscount || 0, t.maxDiscount = t.maxDiscount || 0, { startTime: moment(u).format("YYYY-MM-DD HH:mm"), endTime: moment(f).format("YYYY-MM-DD HH:mm"), stepState: n, chargeItemIds: i, doctorIds: e, isByOrderDate: t.isByOrderDate, patientSearchKeyWord: t.patientSearchKeyWord, minDiscount: t.minDiscount, maxDiscount: t.maxDiscount, tagIds: ei() } },
                kt = function() { e && e.saveAsExcel() },
                dt = function() { var i = n.defer(); return k.getDoctors().success(function(n) { var r = n,
                            f, e;
                        t.isPersonLevel ? r = _.filter(n, function(n) { return n.id === b.providerId }) : t.isDepartmentLevel && (r = b.department ? _.filter(n, function(n) { return n.department === b.department }) : _.filter(n, function(n) { return n.department == null }));
                        t.doctors = r;
                        f = u.find("#doctor").kendoMultiSelect({ placeholder: "全部", dataTextField: "name", dataValueField: "id", dataSource: r, change: gt });
                        t.isPersonLevel && (e = f.data("kendoMultiSelect"), e.value(b.providerId), t.selectedDoctorId = b.providerId);
                        i.resolve() }), i.promise },
                gt = function() { var n = u.find("#doctor").data("kendoMultiSelect");
                    t.selectedDoctorId = n && n.value() != "" ? n.value().join() : "" },
                ni = function() { var i = b.providerId,
                        n = t.selectedDoctorId; return n !== "" ? n : -1 },
                ti = function() { h.chargeItemDic.load().then(function(n) { t.chargeItems = n }) },
                ii = function() { var n = angular.copy(t.chargeItems),
                        i = a.open({ animation: !0, backdrop: "static", template: "<item-dialog-view><\/item-dialog-view>", controller: "ItemDialogCtrl", windowClass: "followup-rule-edit-add-dialog", resolve: { host: function() { return { type: "chargeItem", list: n } } } });
                    i.result.then(function(n) { var u, i, r; if (n) { for (u = n.isSaveAll ? ["全部"] : _.pluck(n.obj, "itemName"), i = "", r = 0; r < u.length; r++) { if (i.length > 10) { i += "..."; break } i += u[r] + "," } t.chargeItemNames = i === "" || i === "全部," ? "全部" : i;
                            angular.forEach(n.obj, function(n) { n.condType = "chargeItem" });
                            t.chargeItems = n.obj } }) },
                ri = function() { u.find("#statusInput").kendoMultiSelect({ placeholder: "全部", dataTextField: "itemName", dataValueField: "value", dataSource: [{ itemName: "未执行", value: 0 }, { itemName: "已执行", value: 1 }, { itemName: "已提前执行", value: 2 }, { itemName: "跳过", value: 3 }] }) },
                ui = function() { t.permissionLevel = b.providerJob == "医生" ? p.getPatientPermissionLevel() : w.PatientPermissionLevel.All;
                    t.isPersonLevel = t.permissionLevel == w.PatientPermissionLevel.Personal;
                    t.isDepartmentLevel = t.permissionLevel == w.PatientPermissionLevel.Department },
                fi = function() { k.listPatientTags().success(function(n) { n = _.filter(n, function(n) { return n.isInactive == !1 }); var t = u.find("#patientTag").data("kendoMultiSelect");
                        t ? t.dataSource.data(n) : u.find("#patientTag").kendoMultiSelect({ maxSelectedItems: 9, dataTextField: "itemName", dataValueField: "id", dataSource: n }) }) },
                ei = function() { var n = null,
                        t = u.find("#patientTag").data("kendoMultiSelect"); return t && (n = t.value()), n };
            (function() { t.patientSearchKeyWord = "";
                t.chargeItems = [];
                t.chargeItemNames = "全部";
                t.selectedDoctorId = "";
                t.isByOrderDate = 1;
                t.pageSize = et();
                t.onSearch = wt;
                t.onExport = kt;
                t.refresh = pt;
                t.openDialog = ii;
                t.minDiscount = 0;
                t.maxDiscount = 100;
                it();
                ti();
                ui();
                ot();
                ri();
                fi();
                i(function() { dt().then(function() { g() }) }) })() } } }]);
managementModule.directive("chargePlanpriceConfirmedView", ["$q", "$log", "$timeout", "$window", "appNav", "aresDialog", "aresNotification", "reportSvc", "providerSvc", "dataDicSvc", "gridOptionUtil", "reportUtil", "$modal", "sessionCache", "localCache", "patientUtil", "enums", "loginContext", "practiceSvc", "formatUtil", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y, p, w, b, k, d) { "use strict"; return { restrict: "AE", replace: !0, templateUrl: "/app/management/views/charge-planprice-confirmed-view.html", scope: { officeId: "=" }, link: function(t, u) {
            function ht() { var n; return t.isGroup ? [{ field: "patientName", title: "患者姓名", width: "110px", hidden: f("patientName") }, { field: "planPrice", title: "应收", width: "120px", template: "#= Ares.FormatMoney(planPrice) #", hidden: f("planPrice"), aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }, { field: "amount", title: "确认营收", width: "120px", template: "#= Ares.FormatMoney(amount) #", hidden: f("amount"), aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }, { field: "actualPrice", title: "实收金额", width: "120px", template: "#= Ares.FormatMoney(actualPrice) #", hidden: f("actualPrice"), aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }, { field: "schedule", title: "应收确认进度", width: "180px", hidden: f("schedule") }] : [{ field: "deductionCode", title: "划扣编号", width: "120px", hidden: f("deductionCode") }, { field: "recordCreatedTimeStr", title: "开单日期", width: "180px", hidden: f("recordCreatedTime") }, { field: "payDateTimeStr", title: "首次收费时间", width: "180px", hidden: f("payDateTimeStr") }, { field: "privateId", title: "病例号", width: "110px", hidden: f("privateId") }, { field: "patientName", title: "患者姓名", width: "110px", hidden: f("patientName") }, { field: "patientSexual", title: "性别", width: "80px", hidden: f("gender") }, { field: "age", title: "年龄", width: "80px", hidden: f("age") }, { field: "patientTagStr", title: "患者标签", template: ut.patientTagTemplate, width: "150px", hidden: f("patientTag") }, { field: "createOfficeName", title: "开单诊所", width: "150px", hidden: f("createOfficeName") }, { field: "consultantName", title: "咨询师", width: "100px", hidden: f("consultantName") }, { field: "itemSuperType", title: "收费大类", width: "120px", hidden: f("chargeItemSuperCatagory") }, { field: "itemType", title: "收费小类", width: "120px", hidden: f("chargeItemCatagory") }, { field: "itemName", title: "项目名称", width: "120px", hidden: f("chargeItemName") }, { field: "stepName", title: "治疗步骤", width: "120px", hidden: f("stepName") }, { field: "planPrice", title: "应收", width: "120px", template: "#= Ares.FormatMoney(planPrice) #", hidden: f("planPrice"), aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }, { field: "amount", title: "确认营收", width: "120px", template: "#= Ares.FormatMoney(amount) #", hidden: f("amount"), aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }, { field: "actualPrice", title: "实收金额", width: "120px", template: "#= Ares.FormatMoney(actualPrice) #", hidden: f("actualPrice"), aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }, { field: "action", title: "状态", width: "80px", hidden: f("action") }, { field: "executionOfficeName", title: "划扣诊所", width: "150px", hidden: f("executionOfficeName") }, { field: "executionTimeStr", title: "划扣时间", width: "180px", hidden: f("executionTime") }, { field: "doctorName", title: "医生", width: "100px", hidden: f("doctorName") }, { field: "nurseName", title: "护士", width: "100px", hidden: f("nurseName") }, { field: "extraProviderName", title: "其他", width: "100px", hidden: f("extraProviderName") }] } var ut = Ares.kendoGridUtil(r, t),
                ft = !1,
                tt, e, s = [],
                et = ["deductionCode", "chargeItemSuperCatagory", "chargeItemCatagory", "performance", "discountPercent", "orderDiscountPrice", "itemDiscountPrice", "giftCertificatePrice", "membershipPrice", "discountPriceSum"],
                g = y.getCache(y.keys.ChargeDeductionColumnHide),
                ot = function() { var n = $(window).height(),
                        t = 130 + u.find("#divCondition").height(),
                        i = n - t,
                        r = i - 81; return Math.max(5, parseInt(r / 40)) },
                f = function(n) { return s.indexOf(n) >= 0 },
                st = function() { var n = g.loadObject();
                    s = n instanceof Array ? n : et },
                it = function() { tt = l.getDefaultTimeSpan(!0);
                    t.timeSpan = _.clone(tt) };
            t.radioCharge = function(n) { if (n) it();
                else { var i = Ares.today(),
                        r = moment(i).startOf("month").format("YYYY-MM-DD"),
                        u = moment(i).startOf("month").add(1, "month").add(-1, "days").format("YYYY-MM-DD");
                    t.timeSpan = { startDate: r, endDate: u } } }; var nt = null,
                ct = function() { var n = u.find("#chargeDeductionReportList"),
                        i = n.offset().top,
                        o = r.innerHeight - i - 10;
                    nt = angular.copy(ht());
                    nt.forEach(function(n) { n.hidden = f(n.field) });
                    e = n.kendoGrid({ excel: { fileName: "确认应收", allPages: !0 }, dataSource: { data: t.pageData, aggregate: t.aggregate }, pageable: c.getPageable(t.pageSize), scrollable: !0, columnMenu: !0, height: o, sortable: !0, resizable: !0, reorderable: !0, selectable: "single", model: { id: "id" }, columns: nt, columnShow: function(n) { s = _.without(s, n.column.field);
                            g.saveObject(s);
                            Ares.DockGridColMenuPos(n.sender) }, columnHide: function(n) { s.push(n.column.field);
                            g.saveObject(s);
                            Ares.DockGridColMenuPos(n.sender) }, columnReorder: function(n) { Ares.DockGridColMenuPos(n.sender) }, dataBound: function(n) { Ares.DockGridColMenuPos(n.sender) } }).data("kendoGrid") },
                lt = function() { i(function() { var n = u.find("#chargeDeductionReportList").data("kendoGrid"),
                            i;
                        n && (i = n.pager, i && i.element.bind("change", function() { var i = n.dataSource.pageSize();
                            t.pageSize = i })) }, 1e3) },
                v = function() { vt().then(function(n) { t.pageData = n;
                        t.aggregate = [{ field: "planPrice", aggregate: "sum" }, { field: "amount", aggregate: "sum" }, { field: "actualPrice", aggregate: "sum" }];
                        at(t.pageData); var i = u.find("#chargeDeductionReportList");
                        i.empty();
                        ct();
                        lt() }) },
                at = function(n) { angular.forEach(n, function(n) { if (n.patientTags && n.patientTags.tags) { var t = "";
                            angular.forEach(n.patientTags.tags, function(n) { t = t + n.itemName + "," });
                            t && (t = t.substring(0, t.length - 1));
                            n.patientTagStr = t } }) },
                vt = function() { var r = n.defer(),
                        i = bt(); return l.checkReportDayLimited(i.startTime, i.endTime).then(function() { return o.getChargePlanPriceConfirmedList(i).success(function(n) { yt(n);
                            t.pageData = n;
                            r.resolve(n) }) }), r.promise },
                yt = function(n) { var i, t; for (d.formatList(n, { payDateTime: "longDateTime" }), i = 0; i < n.length; i++) t = n[i], t.recordCreatedTimeStr = moment(t.recordCreatedTime).format("YYYY-MM-DD HH:mm:ss"), t.executionTimeStr = t.executionTime ? moment(t.executionTime).format("YYYY-MM-DD HH:mm:ss") : "" },
                pt = function() { e && (ft = !1, v()) },
                wt = function() { e ? (e.dataSource.page() != 1 && e.dataSource.page(1), v()) : v() },
                bt = function() { var r = l.getStartEndTime(t),
                        f = ni(),
                        n = $("#statusInput").data("kendoMultiSelect").value(),
                        i, u; return n = n && n.length > 0 ? n.join(",") : -1, i = "-1", t.chargeItems.length > 0 && t.chargeItemNames !== "全部" && (u = _.pluck(t.chargeItems, "id"), i = u.join()), { startTime: r.start, endTime: r.end, stepState: n, chargeItemIds: i, doctorIds: f, isByOrderDate: t.isByOrderDate, patientSearchKeyWord: t.patientSearchKeyWord, tagIds: ei(), isGroup: t.isGroup, stepNames: t.selectedStepNames } },
                kt = function() { e && e.saveAsExcel() },
                dt = function() { var i = n.defer(); return k.getDoctors().success(function(n) { var r = n,
                            f, e;
                        t.isPersonLevel ? r = _.filter(n, function(n) { return n.id === b.providerId }) : t.isDepartmentLevel && (r = b.department ? _.filter(n, function(n) { return n.department === b.department }) : _.filter(n, function(n) { return n.department == null }));
                        t.doctors = r;
                        f = u.find("#doctor").kendoMultiSelect({ placeholder: "全部", dataTextField: "name", dataValueField: "id", dataSource: r, change: gt });
                        t.isPersonLevel && (e = f.data("kendoMultiSelect"), e.value(b.providerId), t.selectedDoctorId = b.providerId);
                        i.resolve() }), i.promise },
                gt = function() { var n = u.find("#doctor").data("kendoMultiSelect");
                    t.selectedDoctorId = n && n.value() != "" ? n.value().join() : "" },
                ni = function() { var i = b.providerId,
                        n = t.selectedDoctorId; return n !== "" ? n : -1 },
                ti = function() { h.chargeItemDic.load().then(function(n) { t.chargeItems = n;
                        t.steps = [];
                        angular.forEach(n, function(n) { n.deductionSteps.length > 0 && angular.forEach(n.deductionSteps, function(n) { _.any(t.steps, function(t) { return t.stepName == n.stepName }) || t.steps.push(n) }) });
                        rt(t.steps) }) },
                ii = function() { var n = angular.copy(t.chargeItems),
                        i = a.open({ animation: !0, backdrop: "static", template: "<item-dialog-view><\/item-dialog-view>", controller: "ItemDialogCtrl", windowClass: "followup-rule-edit-add-dialog", resolve: { host: function() { return { type: "chargeItem", list: n } } } });
                    i.result.then(function(n) { var u, i, r; if (n) { for (u = n.isSaveAll ? ["全部"] : _.pluck(n.obj, "itemName"), i = "", r = 0; r < u.length; r++) { if (i.length > 10) { i += "..."; break } i += u[r] + "," } t.chargeItemNames = i === "" || i === "全部," ? "全部" : i;
                            t.steps = [];
                            angular.forEach(n.obj, function(n) { n.condType = "chargeItem";
                                n.deductionSteps.length > 0 && angular.forEach(n.deductionSteps, function(n) { _.any(t.steps, function(t) { return t.stepName == n.stepName }) || t.steps.push(n) }) });
                            rt(t.steps);
                            t.chargeItems = n.obj } }) },
                ri = function() { u.find("#statusInput").kendoMultiSelect({ placeholder: "全部", dataTextField: "itemName", dataValueField: "value", dataSource: [{ itemName: "创建", value: 4 }, { itemName: "已执行", value: 1 }, { itemName: "跳过", value: 3 }, { itemName: "退金额", value: 5 }, { itemName: "撤销", value: 2 }] }) },
                ui = function() { t.permissionLevel = b.providerJob == "医生" ? p.getPatientPermissionLevel() : w.PatientPermissionLevel.All;
                    t.isPersonLevel = t.permissionLevel == w.PatientPermissionLevel.Personal;
                    t.isDepartmentLevel = t.permissionLevel == w.PatientPermissionLevel.Department },
                fi = function() { k.listPatientTags().success(function(n) { n = _.filter(n, function(n) { return n.isInactive == !1 }); var t = u.find("#patientTag").data("kendoMultiSelect");
                        t ? t.dataSource.data(n) : u.find("#patientTag").kendoMultiSelect({ maxSelectedItems: 9, dataTextField: "itemName", dataValueField: "id", dataSource: n }) }) },
                ei = function() { var n = null,
                        t = u.find("#patientTag").data("kendoMultiSelect"); return t && (n = t.value()), n },
                oi = function(n) { t.selectAction = n;
                    t.isGroup = n == "detail" ? !1 : !0 },
                rt = function(n) { var i = u.find("#step-drop").data("kendoMultiSelect");
                    i ? (t.selectedStepNames = "-1", i.dataSource.data(n)) : u.find("#step-drop").kendoMultiSelect({ placeholder: "全部步骤", maxSelectedItems: 9, dataTextField: "stepName", dataValueField: "stepName", dataSource: n, change: si }) },
                si = function() { var n = u.find("#step-drop").data("kendoMultiSelect");
                    t.selectedStepNames = n && n.value() != "" ? n.value().join() : "-1" };
            (function() { t.isGroup = !1;
                t.selectAction = "detail";
                t.patientSearchKeyWord = "";
                t.timeSpan = l.getDefaultTimeSpan(t.defaultSelect);
                t.chargeItems = [];
                t.chargeItemNames = "全部";
                t.selectedDoctorId = "";
                t.selectedStepNames = "-1";
                t.isByOrderDate = 1;
                t.pageSize = ot();
                t.onSearch = wt;
                t.onExport = kt;
                t.refresh = pt;
                t.openDialog = ii;
                t.switchAction = oi;
                it();
                ti();
                ui();
                st();
                ri();
                fi();
                i(function() { dt().then(function() { v() }) }) })() } } }]);
managementModule.directive("consultPerformanceView", ["$log", "$timeout", "$window", "$q", "appNav", "dataDicSvc", "practiceSvc", "reportSvc", "patientSvc", "localCache", "sessionCache", "gridOptionUtil", "permissionProvider", "reportUtil", "providerSvc", "loginContext", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y, p) { return { restrict: "E", templateUrl: "/app/management/views/consult-performance-view.html", controller: "consultPerformanceCtrl", link: function(n, r) { var s, b, h = c.getCache(c.keys.PageSize),
                w = 10;
            n.timeSpan = {};
            n.searchText = "";
            n.selectDate = "day"; var k = { departments: "", startDate: moment(Ares.today()).format("YYYY-MM-DD"), endDate: moment(Ares.today()).add(1, "day").format("YYYY-MM-DD"), providerIds: "", officeIds: n.selectedOfficeIds },
                f, d = function(t) { e.getDepartmentByOfficeId(t).then(function(t) { var i, u;
                        n.departmentList = t.data;
                        i = { itemName: "全部", id: "" };
                        n.departmentList.splice(0, 0, i);
                        u = r.find("#consultDepartment");
                        f = u.kendoDropDownList({ dataSource: n.departmentList, placeholder: "", dataTextField: "itemName", dataValueField: "itemName", enable: n.isDepartmentEnable, select: function(t) { var i = this.dataItem(t.item.index());
                                n.searchCriteria.departments = i.itemName == "全部" ? "" : i.itemName } }).data("kendoDropDownList") }) },
                o, g = function(t) { y.getWorkProvidersByOffice(t).success(function(t) { var i = _.filter(t, function(n) { return n.job === "咨询师" }),
                            u = r.find("#consult");
                        o = u.kendoMultiSelect({ placeholder: "全部", dataTextField: "name", dataValueField: "id", enable: n.isConsultEnable, dataSource: i, change: function() { var t = r.find("#consult").data("kendoMultiSelect");
                                n.searchCriteria.providerIds = t && t.value() != "" ? t.value().join() : "";
                                n.$apply() } }).data("kendoMultiSelect") }) },
                u = "text-align: center; font-size: 14px; font-weight: bolder;",
                nt = [{ field: "sequenceNum", title: "序号", sortable: !1, width: "80px", attributes: { style: "padding: 0" }, headerAttributes: { style: u }, footerTemplate: "总计" }, { field: "officeName", sortable: !1, title: "所属诊所", width: "100px", headerAttributes: { style: u } }, { field: "providerName", sortable: !1, title: "咨询师", width: "100px", headerAttributes: { style: u } }, { field: "employeeNo", sortable: !1, title: "工号", width: "100px", headerAttributes: { style: u } }, { field: "departmentName", sortable: !1, title: "科室", width: "140px", headerAttributes: { style: u } }, { field: "rechargePerformance", sortable: !1, format: "{0:n}", title: "充值业绩", width: "120px", headerAttributes: { style: u }, aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }, { field: "billingPerformance", sortable: !1, format: "{0:n}", title: "开单业绩", width: "120px", headerAttributes: { style: u }, aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }, { field: "totalPerformance", sortable: !1, format: "{0:n}", title: "总业绩", width: "120px", headerAttributes: { style: u }, aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }, { field: "achievements", sortable: !1, format: "{0:n}", title: "绩效收入", width: "120px", headerAttributes: { style: u }, aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }],
                tt = function() { if (n.pageData) { n.aggregate = [{ field: "rechargePerformance", aggregate: "sum" }, { field: "billingPerformance", aggregate: "sum" }, { field: "totalPerformance", aggregate: "sum" }, { field: "achievements", aggregate: "sum" }];
                        it();
                        s = r.find("#ConsultPerformanceList"); var t = s.offset().top,
                            u = i.innerHeight - t - 20;
                        s.html("");
                        b = s.kendoGrid({ excel: { allPages: !0 }, excelExport: function(n) { var t = new Date,
                                    s = t.getFullYear(),
                                    i = (t.getMonth() + 1).toString(),
                                    r = t.getDate().toString(),
                                    o;
                                i.length == 1 && (i = "0" + i);
                                r.length == 1 && (r = "0" + r); var h = s + i + r,
                                    u = t.getHours().toString(),
                                    f = t.getMinutes().toString(),
                                    e = t.getSeconds().toString();
                                u.length == 1 && (u = "0" + u);
                                f.length == 1 && (f = "0" + f);
                                e.length == 1 && (e = "0" + e);
                                o = u + f + e;
                                n.workbook.fileName = "咨询师绩效" + h + "_" + o + ".xls" }, dataSource: { data: n.pageData, aggregate: n.aggregate }, pageable: l.getPageable(w), scrollable: !0, columnMenu: !0, height: u, sortable: !0, resizable: !0, reorderable: !0, selectable: "single", model: { id: "id" }, columns: nt, columnShow: function(n) { Ares.DockGridColMenuPos(n.sender) }, columnHide: function(n) { Ares.DockGridColMenuPos(n.sender) }, columnReorder: function(n) { Ares.DockGridColMenuPos(n.sender) }, dataBound: function(n) { Ares.DockGridColMenuPos(n.sender) } }).data("kendoGrid") } };
            n.exportExcel = function() { b && b.saveAsExcel() }; var it = function() { var n; if (h && (n = h.loadObject(), w = n.pageSize), !w) { var t = $(window).height(),
                            i = t - 240,
                            r = i - 81;
                        w = Math.max(5, parseInt(r / 30)) } },
                rt = function(t) { var i = window.event ? t.keyCode : t.which;
                    i == 13 && n.search() },
                ut = function() { t(function() { var n = r.find("#ConsultPerformanceList").data("kendoGrid"),
                            t;
                        n && (t = n.pager, t && t.element.bind("change", function() { var t = n.dataSource.pageSize();
                            h && h.saveObject({ pageSize: t }) })) }, 1e3) },
                ft = function() { var t = Ares.today(),
                        i = moment(Ares.today()).startOf("month").toDate(),
                        r = { startDate: i, endDate: t };
                    n.timeSpan = _.clone(r) },
                et = function(t) { t === "previous" ? (n.timeSpan.startDate = moment(n.timeSpan.startDate).add(-1, n.selectDate).toDate(), n.timeSpan.endDate = moment(n.timeSpan.endDate).add(-1, n.selectDate).toDate()) : t === "next" && (n.timeSpan.startDate = moment(n.timeSpan.startDate).add(1, n.selectDate).toDate(), n.timeSpan.endDate = moment(n.timeSpan.endDate).add(1, n.selectDate).toDate()) },
                ot = function(t) { r.find("#btnDay").attr("class", "btn btn-default"); var i = v.getDefaultTimeSpan(); switch (t) {
                        case "all":
                            n.timeSpan.startDate = null;
                            n.timeSpan.endDate = null;
                            n.selectDate = "all"; break;
                        case "day":
                            n.timeSpan.startDate = moment(Ares.today()).toDate();
                            n.timeSpan.endDate = moment(Ares.today()).add(1, "day").toDate();
                            n.selectDate = "day"; break;
                        case "week":
                            n.timeSpan.startDate = moment(Ares.today()).startOf("week").toDate();
                            n.timeSpan.endDate = moment(Ares.today()).endOf("week").toDate();
                            n.selectDate = "week"; break;
                        case "month":
                            n.timeSpan.startDate = i.startTime;
                            n.timeSpan.endDate = i.endTime;
                            n.selectDate = "month"; break;
                        case "custom":
                            n.timeSpan.endDate || ft();
                            n.selectDate = "custom" } },
                st = function() { n.loadOfficeTreeData();
                    n.timeSpan.startDate = moment(Ares.today()).toDate();
                    n.timeSpan.endDate = moment(Ares.today()).toDate();
                    d(n.selectedOfficeIds);
                    g(n.selectedOfficeIds);
                    n.isGroup ? (n.isDepartmentEnable = !1, n.isConsultEnable = !1) : (n.isDepartmentEnable = !0, n.isConsultEnable = !0, n.search()) },
                ht = function(t) { n.selectedOfficeIds = _.pluck(t, "officeId"); var i = p.officeId;
                    n.selectedOfficeIds && n.selectedOfficeIds.length == 1 ? (f.enable(!0), o.enable(!0), i = n.selectedOfficeIds) : n.selectedOfficeIds && n.selectedOfficeIds.length > 1 ? (f.enable(!1), o.enable(!1)) : (f.enable(!1), o.enable(!1), n.selectedOfficeIds = p.officeId);
                    e.getDepartmentByOfficeId(i).then(function(t) { n.departmentList = t.data;
                        n.departmentList.splice(0, 0, { itemName: "全部", id: "" });
                        f.setDataSource(n.departmentList) });
                    y.getWorkProvidersByOffice(i).success(function(n) { var t = _.filter(n, function(n) { return n.job === "咨询师" });
                        o.setDataSource(t) });
                    n.selectedOfficeIds && (n.selectedOfficeIds = n.selectedOfficeIds.join());
                    n.searchCriteria.departments = "";
                    n.searchCriteria.providerIds = "" };
            (function() { n.isGroup = p.isGroup;
                n.selectedOfficeIds = p.officeId;
                n.searchCriteria = k;
                n.onOfficeSelected = ht;
                n.switchDate = ot;
                n.updateDate = et;
                n.isAllowExportConsults = a.isAllowed("performance.consultPerformanceViewExcel");
                n.searchInputKeyup = rt;
                st();
                n.$watch("pageData", function() { tt();
                    ut() }) })() } } }]);
managementModule.directive("consultantWorkSummaryReportView", ["$log", "$window", "$timeout", "gridOptionUtil", "practiceSvc", function(n, t, i, r, u) { "use strict"; return { restrict: "E", replace: !0, scope: { job: "@", isPrivate: "@" }, controller: "ConsultantWorkSummaryReportCtrl", templateUrl: "/app/management/views/consultant-work-summary-report-view.html", link: function(n, f) { var e = null,
                o = null,
                a = Ares.kendoGridUtil(t, n),
                h = [{ field: "totalPrice", aggregate: "sum" }, { field: "consultantName", aggregate: "count" }, { field: "actualPrice", aggregate: "sum" }, { field: "performance", aggregate: "sum" }],
                s = function(n) { var t = "姓名:" + n.value; return t += "--数量:" + n.count, t + ("--总实收:" + Ares.priceToFixed(n.aggregates.actualPrice.sum)) },
                v = n.job == "牙医助理" ? [{ hidden: !0, field: "consultantName", title: n.job, isHidden: !1, isGroupField: !0, width: "80px", groupHeaderTemplate: s }, { field: "name", title: "患者姓名", isHidden: !1, width: "120px", footerTemplate: "总计" }, { field: "privateId", title: "病历号", isHidden: !1, width: "100px" }, { field: "mobile", title: "手机", isHidden: !1, width: "110px" }, { field: "startTime", title: "预约时间", isHidden: !1, width: "140px" }, { field: "payDateTime", title: "收费时间", width: "140px" }, { field: "doctorName", title: "预约医生", isHidden: !1, width: "100px" }, { field: "reason", title: "未成交原因/预估成交金额", width: "160px" }, { field: "transactioncodeStr", title: "预约项目", isHidden: !1, width: "160px" }, { field: "stateStr", title: "预约状态", isHidden: !1, width: "70px" }, { field: "planPrice", title: "应收费用", isHidden: !1, width: "100px", format: "{0:n}", aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }, { field: "actualPrice", title: "实收费用", isHidden: !1, width: "100px", format: "{0:n}", aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }, { field: "performance", title: "绩效收入", isHidden: !0, width: "100px", format: "{0:n}", aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }] : [{ hidden: !0, field: "consultantName", title: n.job, isHidden: !1, isGroupField: !0, width: "80px", groupHeaderTemplate: s }, { field: "name", title: "患者姓名", isHidden: !1, width: "120px", footerTemplate: "总计" }, { field: "privateId", title: "病历号", isHidden: !1, width: "100px" }, { field: "mobile", title: "手机", isHidden: !1, width: "120px" }, { field: "patientTagStr", title: "患者标签", isHidden: !1, template: a.patientTagTemplate, width: "150px" }, { field: "tagStr", title: "自定义标签", isHidden: !1, width: "150px" }, { field: "startTime", title: "预约时间", isHidden: !1, width: "140px" }, { field: "payDateTime", title: "收费时间", width: "140px" }, { field: "doctorName", title: "预约医生", isHidden: !1, width: "100px" }, { field: "checkInType", title: "就诊类型", width: "100px" }, { field: "isChargedStr", title: "是否充值", width: "100px" }, { field: "isDealed", title: "是否成交", width: "100px" }, { field: "reason", title: "未成交原因/预估成交金额", width: "260px" }, { field: "transactioncodeStr", title: "预约项目", isHidden: !1, width: "160px" }, { field: "stateStr", title: "预约状态", isHidden: !1, width: "120px" }, { field: "discount", title: "整单折扣率", isHidden: !1, width: "150px" }, { field: "planPrice", title: "应收", isHidden: !1, width: "100px", format: "{0:n}", aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }, { field: "actualPrice", title: "实收", isHidden: !1, width: "100px", format: "{0:n}", aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }, { field: "actualAmount", title: "实际实收", isHidden: !1, width: "100px", format: "{0:n}", aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }, { field: "performance", title: "绩效收入", isHidden: !0, width: "100px", format: "{0:n}", aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }],
                y = [{ hidden: !0, field: "consultantName", title: n.job, isHidden: !1, isGroupField: !0, width: "80px", groupHeaderTemplate: s }, { field: "name", title: "患者姓名", width: "80px", footerTemplate: "总计" }, { field: "privateId", title: "病历号", width: "100px" }, { field: "mobile", title: "手机", width: "110px" }, { field: "txPlanName", title: "治疗计划名称", width: "140px" }, { field: "recordCreatedTimeStr", title: "创建时间", width: "100px" }, { field: "statusStr", title: "状态", width: "100px" }, { field: "txPlanPrice", title: "预算金额", width: "70px", format: "{0:n}" }, { field: "actualPrice", title: "实收费用", width: "150px", format: "{0:n}", aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }, { hidden: !0, field: "performance", title: "绩效收入", width: "150px", format: "{0:n}", aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }],
                c = function(t) { n.showColumns = t },
                l = function(t) { n.showTxColumns = t },
                p = function() { n.generateColumns(v).then(function(u) { i(function() { var s = angular.copy(u),
                                i, o, h; if (n.gridColumns)
                                for (i = 0; i < n.gridColumns.length; i++) s.push(n.gridColumns[i]);
                            o = f.find(".control-panel");
                            h = t.innerHeight - o.offset().top - o.height() - 10;
                            f.find("#consultantWorkSummaryList").html("");
                            e = f.find("#consultantWorkSummaryList").kendoGrid({ dataSource: { data: n.pageData, aggregate: n.aggregate, group: { field: "consultantName", aggregates: n.aggregate } }, height: h, scrollable: !0, sortable: !0, reorderable: !0, selectable: "single", resizable: !0, columnMenu: !0, columnShow: function(n) { var t = n.sender.columns;
                                    r.updateColumnsOption(r.keys.consultantWorkSummaryGridOption, t, c);
                                    Ares.DockGridColMenuPos(n.sender) }, columnHide: function(n) { var t = n.sender.columns;
                                    r.updateColumnsOption(r.keys.consultantWorkSummaryGridOption, t, c);
                                    Ares.DockGridColMenuPos(n.sender) }, columns: s, columnMenuInit: function(n) { $(n.container).find(".k-sort-asc").remove();
                                    $(n.container).find(".k-sort-desc").remove(); var t = $(n.container).find(".k-menu-group");
                                    t.find("li").each(function(n, t) { var i = $(t).text();
                                        i === "咨询师" && $(t).remove() }) }, excelExport: function(n) { for (var i = n.workbook.sheets[0], t = 1; t < i.rows.length; t++) i.rows[t].type === "footer" && (i.rows[t].cells[1].value = "总计") }, columnReorder: function(n) { Ares.DockGridColMenuPos(n.sender) }, dataBound: function(n) { Ares.DockGridColMenuPos(n.sender) } }).data("kendoGrid") }) }) },
                w = function() { n.generateTxColumns(y).then(function(u) { o == null ? i(function() { var i = f.find(".control-panel"),
                                e = t.innerHeight - i.offset().top - i.height() - 10;
                            o = f.find("#consultantWorkTxPlanSummaryList").kendoGrid({ dataSource: { data: n.txPlanSummary, aggregate: h, group: { field: "consultantName", aggregates: h } }, scrollable: !0, height: e, sortable: !0, selectable: "single", columnMenu: !0, columnShow: function(n) { var t = n.sender.columns;
                                    r.updateColumnsOption(r.keys.consultantWorkTxPlanSummaryReport, t, l);
                                    Ares.DockGridColMenuPos(n.sender) }, columnHide: function(n) { var t = n.sender.columns;
                                    r.updateColumnsOption(r.keys.consultantWorkTxPlanSummaryReport, t, l);
                                    Ares.DockGridColMenuPos(n.sender) }, columns: u, columnReorder: function(n) { Ares.DockGridColMenuPos(n.sender) }, dataBound: function(n) { Ares.DockGridColMenuPos(n.sender) } }).data("kendoGrid") }) : o.dataSource.data(n.txPlanSummary) }) },
                b = function() { var n = f.find("#queryTypeInput");
                    n.kendoDropDownList({ dataSource: [{ itemName: "按收费记录统计" }, { itemName: "按治疗计划统计" }], dataTextField: "itemName", dataValueField: "itemName" }) },
                k = function() { e && e.saveAsExcel() },
                d = function() { u.listPatientTags().success(function(n) { n = _.filter(n, function(n) { return n.isInactive == !1 }); var t = f.find("#patientTag").data("kendoMultiSelect");
                        t ? t.dataSource.data(n) : f.find("#patientTag").kendoMultiSelect({ maxSelectedItems: 9, dataTextField: "itemName", dataValueField: "id", dataSource: n }) }) },
                g = function() { var n = null,
                        t = f.find("#patientTag").data("kendoMultiSelect"); return t && (n = t.value()), n };
            (function() { n.isDealed = -1;
                n.getTagIds = g;
                n.exportExcel = k;
                b();
                d();
                n.$watch("pageData", function() { n.pageData && n.pageData.length > 0 ? (n.isEmpty = !1, p()) : n.isEmpty = !0 });
                n.$watch("txPlanSummary", function() { n.txPlanSummary && n.txPlanSummary.length > 0 ? (n.isTxPlanEmpty = !1, w()) : n.isTxPlanEmpty = !0 }) })() } } }]);
managementModule.directive("followupBorwserView", ["$modal", "$q", "$timeout", "$window", "loginContext", "followupUtil", "appNav", "dataDicSvc", "practiceSvc", "patientUtil", "enums", "permissionProvider", "patientSvc", "followupSvc", "providerSvc", "sessionCache", "aresDialog", "aresNotification", "officeOptionSvc", "eventAggregator", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y, p, w, b, k, d) { "use strict"; return { restrict: "E", replace: !0, controller: "FollowupBorwserCtrl", templateUrl: "/app/management/views/followup-borwser-view.html", scope: { officeId: "=" }, link: function(c, g) { var ut = p.getCache(p.keys.FollowupListSearchCriteria),
                nt = moment(Ares.today()).format("YYYY-MM-DD"),
                st = function(n) { return '<a class="action-btn" action="details" type-id="' + n.id + '">' + n.patientName + "<\/a>" },
                ht = function(n) { var t = "<span>" + n.visitDateTime + "<br />" + (n.followupRuleAction ? "计划" + n.followupRuleAction.showOrder : "") + "<\/span>"; return n.visitDateTime ? t : "" },
                ct = function(n) { var t = '<span title="' + n.visitContent + '" data-toggle="tooltip" data-placement="top" data-container=".followup-borwser-list">' + n.visitContent + "<\/span>"; return n.visitContent ? t : "" },
                lt = function(n) { var t = n.creatorName ? n.creatorName : "",
                        i = n.recordCreatedTime ? n.recordCreatedTime : "",
                        r = "<span>" + t + "<br />" + i + "<\/span>"; return n.visitDateTime ? r : "" },
                at = function(n) { var t = '<span class="overflow-content" title="' + n.visitResult + '">' + n.visitResult + "<\/span>"; return n.visitResult ? t : "" },
                vt = function(n) { var t = '<div style="color: ' + n.statusTextColor + '">' + n.status + '<span class="exceed-sign" style="display: ' + (n.visitTimeExceed ? "inline" : "none") + ' ">超时<\/span><\/div>'; return n.status ? t : "" },
                yt = function(n) { var t = n.executorName ? n.executorName : "",
                        i = n.executeTime ? n.executeTime : ""; return "<span>" + t + "<br />" + i + "<\/span>" },
                pt = function(n) { var r = "",
                        t, i, u; return n.status === "待计划" && (r = '<a class="action-btn" action="exec" type-id="' + n.id + '" title="执行随访" data-toggle="tooltip" data-placement="top" data-container=".followup-borwser-list">执行<\/a>'), t = "", n.status !== "已取消" && (t = '<a class="action-btn" action="edit" type-id="' + n.id + '" title="修改随访" data-toggle="tooltip" data-placement="top" data-container=".followup-borwser-list">修改<\/a>'), i = "", c.isDeleteFollowupAllowed && (i = '<a class="action-btn" action="delete" type-id="' + n.id + '" title="删除随访" data-toggle="tooltip" data-placement="top" data-container=".followup-borwser-list">删除<\/a>'), u = '<a class="action-btn" action="editLog" type-id="' + n.id + '" title="改动日志" data-toggle="tooltip" data-placement="top" data-container=".followup-borwser-list">日志<\/a>', r + t + i + u },
                wt = function() { return [{ field: "", title: "患者姓名", width: "120px", template: st }, { field: "mobile", title: "手机号", width: "130px" }, { field: "privateId", title: "病历号", width: "130px" }, { field: "consultantName", title: "咨询师", width: "100px", hidden: !(c.isRegularChain && c.isEnableConsultantDiagnose) }, { field: "", title: "计划随访时间", width: "130px", template: ht }, { field: "department", title: "医生科室", width: "100px" }, { field: "doctorName", title: "随访医生", width: "100px" }, { field: "otherProviderName", title: "随访人员", width: "100px" }, { field: "", title: "随访内容", width: "260px", template: ct }, { filed: "", title: "随访结果", width: "260px", template: at }, { field: "executorName", title: "随访人/随访时间", width: "130px", template: yt }, { field: "category", title: "随访类型", width: "130px" }, { field: "examDateTime", title: "就诊时间", width: "130px" }, { field: "ruleName", title: "随访模板", width: "130px" }, { field: "subject", title: "随访项目", width: "100px" }, { field: "creatorName", title: "创建人/时间", width: "130px", template: lt }, { field: "channel", title: "沟通方式", width: "130px" }, { field: "satisfaction", title: "满意度", width: "100px" }, { field: "", title: "随访状态", width: "120px", locked: !0, template: vt }, { field: "", title: "操作", width: "150px", locked: !0, template: pt }] },
                bt = function() { var n = g.find(".followup-borwser-list");
                    n.html(""); var t = n.offset().top,
                        i = r.innerHeight - t - 50 - (window.Ares3 ? 20 : 0),
                        u = n.kendoGrid({ dataSource: { data: c.followups }, height: i, model: { id: "id" }, columns: wt(), dataBound: function() {} }).data("kendoGrid") },
                kt = function() { g.find(".followup-borwser-list").on("click", "a.action-btn", function() { var t = $(this),
                            i = t.attr("type-id"),
                            r = t.attr("action"),
                            n = _.find(c.followups, function(n) { return n.id === Number(i) }); switch (r) {
                            case "details":
                                ii(n.patientId); break;
                            case "exec":
                                fi(n).then(function() { tt() }); break;
                            case "edit":
                                ui(n).then(function() { tt() }); break;
                            case "delete":
                                ei(n).then(function() { tt() }); break;
                            case "editLog":
                                oi(n.id); break;
                            default:
                                return } }) },
                tt = function() { bt();
                    i(function() { g.find("[data-toggle=tooltip]").tooltip() }) },
                ft = [{ field: "patientName", title: "患者姓名" }, { field: "mobile", title: "手机号" }, { field: "privateId", title: "病历号" }, { field: "visitDateTime", title: "计划随访时间" }, { field: "department", title: "医生科室" }, { field: "doctorName", title: "随访医生" }, { field: "otherProviderName", title: "随访人员" }, { field: "visitContent", title: "随访内容" }, { field: "category", title: "随访类型" }, { field: "examDateTime", title: "就诊时间" }, { field: "ruleName", title: "随访模板" }, { field: "subject", title: "随访项目" }, { field: "creatorName", title: "创建人" }, { field: "recordCreatedTime", title: "创建时间" }, { field: "channel", title: "沟通方式" }, { field: "executeTime", title: "随访时间" }, { field: "executorName", title: "随访人" }, { field: "satisfaction", title: "满意度" }, { field: "visitResult", title: "随访结果" }, { field: "status", title: "随访状态" }, ],
                dt = function(n) { rt("visitDateTime");
                    Ares.sensors.trackDropDownEvent("FollowupBorwser", n) },
                gt = function() { rt("executeTime") },
                it = function() { i(function() { ni() }, 100) },
                ni = function() { ut.saveObject(c.pageState);
                    c.getPagedFollowups().then(function(n) { var t = n.items;
                        c.totalCount = n.totalCount;
                        t.forEach(function(n) { n.examDateTime = n.examDateTime ? moment(n.examDateTime).format("YYYY/MM/DD") : "";
                            n.visitDateTime = n.visitDateTime ? moment(n.visitDateTime).format("YYYY/MM/DD") : "";
                            n.recordCreatedTime = moment(n.recordCreatedTime).format("YYYY/MM/DD");
                            n.executeTime = n.executeTime ? moment(n.executeTime).format("YYYY/MM/DD") : "";
                            n.status === "待计划" ? (n.statusTextColor = "#F7A51D", n.visitTimeExceed = moment(n.visitDateTime) < moment(Ares.today())) : n.status === "随访完成" ? n.statusTextColor = "#00A6C9" : n.status === "已取消" && (n.statusTextColor = "#9397A2");
                            n.showEditBtn = !0;
                            n.showViewBtn = !0;
                            n.status === "随访完成" || n.status === "已取消" || n.status === "未成功" ? n.showEditBtn = !1 : n.showViewBtn = !1 });
                        c.followups = t;
                        tt() }) },
                rt = function(n) { var t;
                    n && n !== "visitDateTime" || (c.pageState.visitDateTimeType == 2 ? (t = moment(nt).add(1, "d").format("YYYY-MM-DD"), c.pageState.startDate = t, c.pageState.endDate = t) : c.pageState.visitDateTimeType == 1 ? (c.pageState.startDate = nt, c.pageState.endDate = nt) : c.pageState.visitDateTimeType == 0 && (c.pageState.startDate = null, c.pageState.endDate = null));
                    n && n !== "executeTime" || (c.pageState.executeTimeType == 2 ? (t = moment(nt).add(1, "d").format("YYYY-MM-DD"), c.pageState.executeStartDate = t, c.pageState.executeEndDate = t) : c.pageState.executeTimeType == 1 ? (c.pageState.executeStartDate = nt, c.pageState.executeEndDate = nt) : c.pageState.executeTimeType == 0 && (c.pageState.executeStartDate = null, c.pageState.executeEndDate = null)) },
                ti = function() { var n, t, r, f;
                    c.isRegularChain = c.$root.isRegularChain;
                    k.getOfficeOption(k.optionKeys.EnableConsultantDiagnose).then(function(n) { c.isEnableConsultantDiagnose = n });
                    n = { statusType: -1, visitDateTimeType: 1, startDate: nt, endDate: nt, advancedSearch: !1, pageIndex: 1, pageSize: 15 };
                    t = ut.loadObject();
                    t && _.extend(n, t);
                    n.officeIds && n.officeIds.length != 0 || (n.officeIds = [u.officeId]);
                    c.pageState = n;
                    c.pageState.officeIds && (c.selectedOfficeIds = c.pageState.officeIds);
                    rt();
                    it();
                    c.isDeleteFollowupAllowed = l.isDeleteFollowupAllowed;
                    s.getDoctors().success(function(n) { r = n;
                        c.pageState.department && (n = n.filter(n => n.department == c.pageState.department));
                        g.find(".doctor-dropdown").kendoDropDownList({ dataSource: n, optionLabel: "全部", dataTextField: "name", dataValueField: "id", filter: "contains", select: function(n) { var t = n.sender.element[0].id,
                                    i = this.dataItem(n.item);
                                t === "followup-doctor" && (c.pageState.doctorId = i.id, Ares.sensors.trackDropDownEvent("FollowupBorwser", "随访医生")) } }) });
                    o.departmentDic.load().then(function(n) { g.find("#followup-doctor-department").kendoDropDownList({ dataSource: n, optionLabel: "全部", dataTextField: "itemName", dataValueField: "itemName", filter: "contains", value: c.pageState.department, select: function(n) { var u = this.dataItem(n.item),
                                    t, f, i;
                                r && (t = r, u.itemName && (t = t.filter(n => n.department == u.itemName)), c.pageState.doctorId && (f = t.find(n => n.id == c.pageState.doctorId), f || (c.pageState.doctorId = null)), i = g.find("#followup-doctor").data("kendoDropDownList"), i && i.setDataSource(t)) } }) });
                    y.getOtherProvider().success(function(n) { g.find(".provider-dropdown").kendoDropDownList({ dataSource: n, optionLabel: "全部", dataTextField: "name", dataValueField: "id", filter: "contains", select: function(n) { var i = n.sender.element[0].id,
                                    t = this.dataItem(n.item);
                                i === "followup-provider" ? (c.pageState.otherProviderId = t.id, Ares.sensors.trackDropDownEvent("FollowupBorwser", "随访人员")) : i === "followup-executor" && (t.id > 0 ? (c.pageState.executorProviderId = t.id, c.pageState.executorId = t.userID || -10) : (c.pageState.executorProviderId = null, c.pageState.executorId = null)) } }); var t = angular.copy(n);
                        t.unshift({ userID: -1, name: "系统", id: -1 });
                        g.find("#followup-creator").kendoDropDownList({ dataSource: t, optionLabel: "全部", dataTextField: "name", dataValueField: "id", filter: "contains", value: c.pageState.creatorProviderId, select: function(n) { var t = this.dataItem(n.item);
                                t.id ? (c.pageState.creatorProviderId = t.id, c.pageState.creatorId = t.userID || -10) : (c.pageState.creatorProviderId = null, c.pageState.creatorId = null);
                                Ares.sensors.trackDropDownEvent("FollowupBorwser", "创建人") } }) });
                    s.getFollowupCategories().success(function(n) { g.find("#followup-category").kendoDropDownList({ dataSource: n, optionLabel: "全部", dataTextField: "itemName", dataValueField: "itemName", value: c.pageState.category }) });
                    o.consultItemDic.loadActive().then(function(n) { g.find("#followup-subject").kendoDropDownList({ dataSource: n, optionLabel: "全部", dataTextField: "itemName", dataValueField: "itemName", value: c.pageState.subject }) });
                    o.systemsettingDic.loadActive({ itemType: "满意度" }).then(function(n) { g.find("#followup-satisfaction").kendoDropDownList({ dataSource: n, optionLabel: "全部", dataTextField: "itemName", dataValueField: "itemName", value: c.pageState.satisfaction }) });
                    f = g.find(".table-body");
                    i(function() { var n = f.find('[data-toggle="tooltip"]');
                        n.tooltip() }) },
                ii = function(n) { return e.goToPatient(n), !1 },
                ri = function(n) { e.goToFollowupDetail(n.patientId, n.id, n.status, "followupCenter.list") },
                et = function(n, i) { var r = t.defer(); return t.all([a.getFollowup(n), a.getPatientsHeadInfo([i])]).then(function(n) { var t = n[0].data,
                            i = n[1].data[0];
                        r.resolve([t, i]) }), r.promise },
                ui = function(n) { if (n.officeId !== u.officeId) { w.warn("信息", "不可修改其他诊所的随访记录。"); return } return h.checkFollowupPrivilege(n, "edit").then(function() { et(n.id, n.patientId).then(function(n) { f.openEditFollowupDialog(n[0], n[1]).then(function(n) { n && (it(), Ares.sensors.track("PatientFollowup", { OperationType: "随访记录修改" })) }) }) }) },
                fi = function(n) { if (n.officeId !== u.officeId) { w.warn("信息", "不可执行其他诊所的随访记录。"); return } return h.checkFollowupPrivilege(n, "view").then(function() { et(n.id, n.patientId).then(function(n) { f.openExecuteFollowupDialog(n[0], n[1]).then(function(n) { n && (it(), Ares.sensors.track("PatientFollowup", { OperationType: "随访记录执行" })) }) }) }) },
                ei = function(n) { return h.checkFollowupPrivilege(n, "delete").then(function() { w.confirm("删除随访记录", "确定要删除此随访记录？").then(function() { v.deleteFollowup(n.id).success(function() { it() }).error(function(n) { b.error(n.data) }) }) }) },
                oi = function(t) { var i = n.open({ animation: !0, backdrop: "static", template: "<operation-log-list-view><\/operation-log-list-view>", controller: "OperationLogListCtrl", size: "lg", windowClass: "operation-log-dialog", resolve: { host: function() { return { id: t, type: "Followup" } } } }) },
                si = function() { i(function() { c.getPagedFollowups(!0).then(function(n) { var i = n && n.totalCount > 0 && n.items && n.items.length > 0 ? n.items[0].isOverflow : !1,
                                t;
                            i ? c.createFollowupListBackgroundReport() : (c.isRegularChain && c.isEnableConsultantDiagnose && ft.splice(3, 0, { field: "consultantName", title: "咨询师" }), t = { criteria: ot(), columns: ft }, v.exportFollowUp(t)) }) }, 100) },
                hi = function() { c.pageState.advancedSearch = !c.pageState.advancedSearch;
                    c.listHeight = c.pageState.advancedSearch ? { height: angular.element(window).height() - 280 - (window.Ares3 ? 20 : 0) } : { height: angular.element(window).height() - 240 - (window.Ares3 ? 20 : 0) } },
                ot = function() { var n = { statusType: c.pageState.statusType || -1, startDate: c.pageState.startDate, endDate: moment(c.pageState.endDate).add(1, "d").format("YYYY-MM-DD"), category: c.pageState.category, isInactive: !1, pageIndex: c.pageState.pageIndex, pageSize: c.pageState.pageSize, sortField: "VisitDateTime", IsAscending: !1, officeIds: c.pageState.officeIds }; return c.pageState.advancedSearch ? (n.otherProviderId = c.pageState.otherProviderId || -1, n.department = c.pageState.department || -1, n.doctorId = c.pageState.doctorId || -1, n.subject = c.pageState.subject, n.creatorId = c.pageState.creatorId || -2, n.executeStartDate = c.pageState.executeStartDate, n.executeEndDate = c.pageState.executeEndDate ? moment(c.pageState.executeEndDate).add(1, "d").format("YYYY-MM-DD") : null, n.executorId = c.pageState.executorId || -1, n.satisfaction = c.pageState.satisfaction || "") : (n.otherProviderId = -1, n.department = -1, n.doctorId = -1, n.subject = null, n.creatorId = -2, n.executeStartDate = null, n.executeEndDate = null, n.executorId = -1), n };
            (function() { c.isShowOfficeDrop = u.isGroup && u.isRootGroup;
                c.onVisitDateTimeSelect = dt;
                c.onExecuteTimeSelect = gt;
                c.searchFollowups = it;
                c.viewFollowup = ri;
                c.exportFollowUp = si;
                c.showOrHideAdvancedSearch = hi;
                c.getSearchCriteria = ot;
                c.listHeight = { height: angular.element(window).height() - 280 - (window.Ares3 ? 20 : 0) };
                c.selectedOfficeIds = [];
                c.onOfficeSelectorHidden = function(n) { if (n !== null && n.length > 0) { var t = _.pluck(n, "id");
                        c.selectedOfficeIds = t;
                        c.pageState.officeIds = t } else c.selectedOfficeIds = [], c.pageState.officeIds = [] };
                ti();
                kt();
                window.Ares3 && d.subscribe(c, d.events.sidebarSubMenuToggle, function() { i(function() { tt() }) }) })() } } }]);
managementModule.directive("groupPerformanceChargeCategoryView", ["$q", "$window", "dataDicSvc", "gridOptionUtil", "loginContext", "moduleOptionProvider", "practiceSvc", "providerSvc", "reportUtil", "$rootScope", "officeSvc", "officeSelectorUtil", function(n, t, i, r, u) { return { restrict: "E", templateUrl: "/app/management/views/group-performance-charge-category-view.html", controller: "GroupPerformanceChargeCategoryCtrl", link: function(n, i) { var f, o = function(t) { n.getOfficeDepartments(t).then(function(t) { f ? f.setDataSource(t.data) : f = i.find("#department").kendoMultiSelect({ placeholder: "全部", dataTextField: "itemName", dataValueField: "itemName", enable: !1, dataSource: t.data }).data("kendoMultiSelect");
                        f.enable(n.isEnabled) }) },
                e, s = function(t) { n.getOfficeProviders(t).then(function(t) { e ? e.setDataSource(t) : e = i.find("#provider").kendoMultiSelect({ placeholder: "全部", dataTextField: "name", dataValueField: "id", enable: !1, dataSource: t }).data("kendoMultiSelect");
                        e.enable(n.isEnabled) }) },
                h = function() { var t = i.find("#doctorChargeCategoryReportList").data("kendoGrid");
                    t && n.dataSource.length > 0 && t.saveAsExcel() },
                c = function() { var t = n.selectCategory === !0 ? i.find("#provider").data("kendoMultiSelect") : i.find("#department").data("kendoMultiSelect"); return t && t.value().length > 0 ? t.value().join() : null },
                l = function() { var u = i.find(".group-performance-charge-category-browse"),
                        s = t.innerHeight - u.offset().top - u.height() - 53,
                        f = i.find("#doctorChargeCategoryReportList"),
                        e, o;
                    f.html("");
                    e = { data: n.dataSource, aggregate: n.aggregate };
                    o = r.getDefaultGridOption(e, n.gridColumns, s);
                    f.kendoGrid(o).data("kendoGrid") };
            (function() { n.isEnabled = !1;
                n.initOfficeDepartmentsSelect = o;
                n.initOfficeProvidersSelect = s;
                n.getProviders = c;
                n.initGrid = l;
                o(u.officeId);
                s(u.officeId);
                n.exportExcel = h })() } } }]);
managementModule.directive("managementHomeView", ["$log", "$timeout", "$state", "appNav", function(n, t, i, r) { return { restrict: "E", templateUrl: "/app/management/views/management-home-view.html", scope: { officeId: "=" }, controller: "ManagementHomeCtrl", link: function(n) { var t = function(n) { r.switchState(n, i) },
                i = function() { var t = n.officeId; return { officeId: t } };
            (function() { n.switchState = t })() } } }]);
managementModule.directive("performanceChargeCategoryView", ["$log", "$timeout", "$filter", "$window", "appNav", "dataDicSvc", "providerSvc", "loginContext", "printUtil", "gridOptionUtil", function(n, t, i, r, u, f, e, o, s, h) { "use strict"; return { restrict: "E", replace: !0, controller: "PerformanceChargeCategoryCtrl", templateUrl: "/app/management/views/performance-charge-category-view.html", scope: { job: "@" }, link: function(n, t) {
            function u() { var i = t.find("#doctorChargeCategoryReportList").width();
                n.gridColumns.length * 120 >= i && (n.gridColumns[1].locked = !0) }

            function e() { var i = t.find("#doctorChargeCategoryReportList").width(),
                    r = _.filter(n.gridColumns, function(n) { return !n.hidden });
                r.length * 120 >= i && angular.forEach(n.gridColumns, function(n) { n.width = "70px" }) } var c = function() { var e = t.find(".control-panel"),
                        s = r.innerHeight - e.offset().top - e.height() - 25,
                        f, o;
                    u();
                    f = t.find("#doctorChargeCategoryReportList");
                    f.html("");
                    o = n.selectCategory ? { data: n.dataSource, aggregate: n.aggregate } : { data: n.dataSource, aggregate: n.aggregate, group: { field: "department", aggregates: n.aggregate } };
                    n.loadColumnsOption().then(function() { var t = h.getDefaultGridOption(o, n.gridColumns, s);
                        n.job === "doctor" ? (t.columnShow = function(n) { var t = n.sender.columns;
                            h.updateColumnsOption(h.keys.chargeCategroyDoctorReportGridOption, t, i) }, t.columnHide = function(n) { var t = n.sender.columns;
                            h.updateColumnsOption(h.keys.chargeCategroyDoctorReportGridOption, t, i) }) : n.job === "consult" ? (t.columnShow = function(n) { var t = n.sender.columns;
                            h.updateColumnsOption(h.keys.chargeCategroyConsultReportGridOption, t, i) }, t.columnHide = function(n) { var t = n.sender.columns;
                            h.updateColumnsOption(h.keys.chargeCategroyConsultReportGridOption, t, i) }) : (t.columnShow = function(n) { var t = n.sender.columns;
                            h.updateColumnsOption(h.keys.chargeCategroyNurseReportGridOption, t, i) }, t.columnHide = function(n) { var t = n.sender.columns;
                            h.updateColumnsOption(h.keys.chargeCategroyNurseReportGridOption, t, i) });
                        f.kendoGrid(t).data("kendoGrid") }) },
                l = function() { var f = r.innerHeight - 170,
                        i, u; return e(), n.gridColumns[1].locked = !1, i = t.find("#hiddenPrintGrid"), i.html(""), u = n.selectCategory ? { data: n.dataSource, aggregate: n.aggregate } : { data: n.dataSource, aggregate: n.aggregate, group: { field: "department", aggregates: n.aggregate } }, i.kendoGrid({ dataSource: u, scrollable: !1, width: "100%", height: f, sortable: !1, resizable: !1, selectable: !1, columns: n.gridColumns }).data("kendoGrid"), i },
                a = function() { var i = t.find("#doctorChargeCategoryReportList").data("kendoGrid");
                    i && n.dataSource.length > 0 && i.saveAsExcel() },
                v = function() { n.getOfficeProviders().then(function(n) { t.find("#provider").kendoMultiSelect({ placeholder: "全部", dataTextField: "name", dataValueField: "id", dataSource: n }) }) },
                y = function() { n.getOfficeDepartments().success(function(n) { t.find("#department").kendoMultiSelect({ placeholder: "全部", dataTextField: "itemName", dataValueField: "itemName", dataSource: n }) }) },
                p = function() { var i = n.selectCategory === !0 ? t.find("#provider").data("kendoMultiSelect") : t.find("#department").data("kendoMultiSelect"); return i && i.value().length > 0 ? i.value().join() : null },
                w = function() { var i = l(),
                        t = n.printSetting,
                        r = f.officeDic.getItemSync(o.officeId);
                    t.title = r.name + n.jobName + "收费大类";
                    t.payDate = moment(n.timeSpan.startDate).format("YYYY-MM-DD") == moment(n.timeSpan.endDate).format("YYYY-MM-DD") ? moment(n.timeSpan.startDate).format("YYYY.MM.DD") : moment(n.timeSpan.startDate).format("YYYY.MM.DD") + " - " + moment(n.timeSpan.endDate).format("YYYY.MM.DD");
                    t.payType = n.selectActualPrice == 1 ? "实收" : n.selectActualPrice == 0 ? "应收" : "绩效";
                    t.printTime = moment().format("YYYY.MM.DD HH:mm:ss");
                    s.printGrid(t, i) },
                i = function(t) { n.showColumns = t };
            (function() { n.print = w;
                n.exportExcel = a;
                n.getProviders = p;
                v();
                y();
                n.$watch("dataSource", function() { n.dataSource && n.dataSource.length > 0 && (t.find("#doctorChargeCategoryReportList").show(), c());
                    n.dataSource && n.dataSource.length <= 0 && t.find("#doctorChargeCategoryReportList").hide() });
                n.search("load") })() } } }]);
managementModule.directive("performanceChargeClassView", ["$log", "$timeout", "$filter", "$window", "appNav", "enums", function() { "use strict"; return { restrict: "E", replace: !0, controller: "PerformanceChargeClassCtrl", templateUrl: "/app/management/views/performance-charge-class-view.html", scope: { officeId: "=" }, link: function(n, t) { var r, i, u = function() { n.pageData && (r = t.find("#doctorChargeClassReportList"), i = r.kendoGrid({ dataSource: { data: n.pageData }, scrollable: !1, selectable: "single", sortable: !0, model: { id: "id" }, columns: n.gridColumns }).data("kendoGrid")) },
                f = function() { i && i.dataSource.data(n.pageData) };
            n.exportExcel = function() { i && i.saveAsExcel() },
                function() { n.$watch("pageData", function() { i ? u() : u() }) }() } } }]);
managementModule.directive("performanceChargeDetailView", ["$log", "$timeout", "$q", "$filter", "$window", "$modal", "appNav", "dataDicSvc", "providerSvc", "loginContext", "printUtil", function(n, t, i, r, u, f, e, o, s, h, c) { "use strict"; return { restrict: "E", replace: !0, controller: "PerformanceChargeDetailCtrl", templateUrl: "/app/management/views/performance-charge-detail-view.html", scope: { job: "@" }, link: function(n, t) {
            function k(t) { t && n.getChargeOrderPatientInfo(t, n.selectActualPrice).then(function(n) { var t = f.open({ animation: !0, backdrop: "static", template: "<ares-grid-dialog><\/ares-grid-dialog>", controller: "aresGridDialogCtrl", windowClass: "ares-grid-dialog", resolve: { host: function() { return { title: "患者信息", data: n.data, columns: [{ field: "privateId", title: "病历号", width: "80px" }, { field: "name", title: "患者姓名", width: "80px" }, { field: "gender", title: "性别", width: "40px" }, { field: "age", title: "年龄", width: "40px" }, { field: "mobile", title: "手机号码", width: "100px" }, { field: "apptDate", title: "就诊日期", width: "100px", template: "#= !apptDate ? '' : kendo.toString(kendo.parseDate(apptDate, 'yyyy-MM-ddTHH:mm:ss'), 'yyyy-MM-dd') #" }, { field: "doctorName", title: "预约医生", width: "80px" }, { field: "amount", title: "金额", width: "80px" }] } } } });
                    t.result.then(function() { t = null }) }) }

            function d() { t.find("#doctorChargeDetailReportList").on("dblclick", "tr.k-state-selected", function() { var n = t.find("#doctorChargeDetailReportList").data("kendoGrid"),
                        i = n.dataItem(t.find(this));
                    k(i.chargeOrderDetailIds) }) } var e = [{ field: "itemCount", aggregate: "sum" }, { field: "planPrice", aggregate: "sum" }, { field: "actualPrice", aggregate: "sum" }, ],
                r = function(t) { var r = n.selectActualPrice == 1 || n.selectActualPrice == 2 ? t.aggregates.actualPrice.sum : t.aggregates.planPrice.sum,
                        i = n.selectCategory ? "姓名:" + n.pageData.find(function(n) { return n.providerId === t.value }).providerName : "科室:" + t.value; return i += "   数量:" + Ares.priceToFixed(t.aggregates.itemCount.sum), (h.isSensitiveAmountAllowed || h.isTenantAdmin) && (i += "   金额:" + Ares.priceToFixed(r)), i },
                l = function() { var t = [{ hidden: !0, field: "department", title: "科室", width: "80px", groupHeaderTemplate: r }, { hidden: !0, menu: !1, field: "providerId", title: "编号", width: "20px", groupHeaderTemplate: r }, { hidden: !1, field: "providerName", title: n.jobName, width: "80px", footerTemplate: "总计", groupHeaderTemplate: r }, { hidden: !1, field: "itemName", title: "收费项", width: "300px" }, { hidden: !1, field: "itemCount", title: "数量", width: "80px", format: "{0:n}", aggregates: ["sum"], footerTemplate: "#=Ares.priceToFixed(sum)#" }, { hidden: !0, field: "fristPayDateTimeStr", title: "首次收费时间", width: "100px" }, ]; return (h.isSensitiveAmountAllowed || h.isTenantAdmin) && (n.selectActualPrice == 1 || n.selectActualPrice == 2 ? t.splice(5, 0, { hidden: !1, field: "actualPrice", title: "金额", width: "80px", format: "{0:n}", aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }) : n.selectActualPrice == 0 && t.splice(5, 0, { hidden: !1, field: "planPrice", title: "金额", width: "80px", format: "{0:n}", aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" })), t },
                a = function() { var t = i.defer(),
                        r = angular.copy(l()); return n.showColumns && angular.forEach(r, function(t) { var i = _.find(n.showColumns, function(n) { return n == t.field });
                        t.hidden = i ? !1 : !0 }), t.resolve(r), t.promise },
                v = function() { a().then(function(i) { var r = t.find(".control-panel"),
                            f = u.innerHeight - r.offset().top - r.height() - 25;
                        t.find("#doctorChargeDetailReportList").html("");
                        t.find("#doctorChargeDetailReportList").kendoGrid({ dataSource: { data: n.pageData, aggregate: e, group: { field: n.selectCategory ? "providerId" : "department", aggregates: e } }, columnMenu: !0, columnShow: function(t) { var r = t.sender.columns,
                                    i = s(r);
                                i && n.updateColumnsOption(i);
                                Ares.DockGridColMenuPos(t.sender) }, columnHide: function(t) { var r = t.sender.columns,
                                    i = s(r);
                                i && n.updateColumnsOption(i);
                                Ares.DockGridColMenuPos(t.sender) }, columnReorder: function(n) { Ares.DockGridColMenuPos(n.sender) }, dataBound: function(n) { Ares.DockGridColMenuPos(n.sender) }, columnMenuInit: function(n) { $(n.container).find(".k-sort-asc").remove();
                                $(n.container).find(".k-sort-desc").remove() }, scrollable: !0, height: f, sortable: !0, reorderable: !0, selectable: "single", resizable: !0, model: { id: "id" }, columns: i }).data("kendoGrid") }) },
                s = function(n) { var r = _.filter(n, function(n) { return n.hidden === !1 }),
                        t = _.pluck(r, "field"),
                        i; return t && (i = _.find(t, function(n) { return n === "actualPrice" || n === "planPrice" }), i && (t.indexOf("actualPrice") > -1 ? t.push("planPrice") : t.indexOf("planPrice") > -1 && t.push("actualPrice"))), t ? t.join() : "" };
            n.exportExcel = function() { var n = t.find("#doctorChargeDetailReportList").data("kendoGrid");
                n && n.saveAsExcel() }; var y = function() { n.getOfficeProviders().then(function(n) { t.find("#provider").kendoMultiSelect({ placeholder: "全部", dataTextField: "name", dataValueField: "id", dataSource: n }) }) },
                p = function() { n.getOfficeDepartments().success(function(n) { t.find("#department").kendoMultiSelect({ placeholder: "全部", dataTextField: "itemName", dataValueField: "itemName", dataSource: n }) }) },
                w = function() { var i = n.selectCategory === !0 ? t.find("#provider").data("kendoMultiSelect") : t.find("#department").data("kendoMultiSelect"); return i && i.value().length > 0 ? i.value().join() : null },
                b = function() { var i = { title: "医生收费大类", payDate: null, payType: "", printTime: null },
                        u = o.officeDic.getItemSync(h.officeId),
                        f = n.job === "doctor" ? "医生" : "护士",
                        r;
                    i.title = u.name + f + "收费明细";
                    i.payDate = n.defaultSelect ? moment(n.timeSpan.startTime).format("YYYY.MM.DD") : moment(n.timeSpan.startTime).format("YYYY.MM.DD") + " - " + moment(n.timeSpan.endTime).format("YYYY.MM.DD");
                    i.payType = n.selectActualPrice == 1 ? "实收" : n.selectActualPrice == 0 ? "应收" : "绩效";
                    i.printTime = moment().format("YYYY.MM.DD HH:mm:ss");
                    r = t.find("#doctorChargeDetailReportList");
                    c.printGrid(i, r) };
            (function() { d();
                y();
                p();
                n.print = b;
                n.getProviders = w;
                n.$watch("pageData", function() { n.pageData && n.pageData.length > 0 && (t.find("#doctorChargeDetailReportList").show(), v());
                    n.pageData && n.pageData.length <= 0 && t.find("#doctorChargeDetailReportList").hide() });
                n.search("load") })() } } }]);
managementModule.directive("performanceDoctorApptView", ["$log", "$timeout", "$filter", "$window", "appNav", "dataDicSvc", "providerSvc", "gridOptionUtil", function(n, t, i, r, u, f, e, o) { "use strict"; return { restrict: "E", replace: !0, controller: "PerformanceDoctorApptCtrl", templateUrl: "/app/management/views/performance-doctor-appt-view.html", scope: { officeId: "=" }, link: function(n, t) { var i, f = function() { var u = t.find(".control-panel"),
                        e = r.innerHeight - u.offset().top - u.height() - 25,
                        f;
                    i = t.find("#doctorApptCountReportList");
                    i.html("");
                    f = o.getDefaultGridOption({ data: n.pageData, aggregate: n.aggregates }, n.columns, e);
                    i.kendoGrid(f).data("kendoGrid") },
                u;
            n.exportExcel = function() { var n = $("#doctorApptCountReportList").data("kendoGrid");
                n && n.saveAsExcel() };
            u = function() { e.getOtherProvider().success(function(n) { var i = _.filter(n, function(n) { return n.job === "医生" });
                    t.find("#doctor").kendoMultiSelect({ placeholder: "全部", dataTextField: "name", dataValueField: "id", dataSource: i }) }) };
            n.getDoctorIds = function() { var n = t.find("#doctor").data("kendoMultiSelect"); return n && n.value() != "" ? n.value().join() : "-1" },
                function() { u();
                    n.$watch("pageData", function() { f() }) }() } } }]);
managementModule.directive("performanceHomeView", ["$q", "newReportGuideUtil", "appNav", "enums", "localCache", "officeOptionSvc", "moduleOptionProvider", "loginContext", "$injector", function(n, t, i, r, u, f, e, o, s) { "use strict"; return { restrict: "E", templateUrl: "/app/management/views/performance-home-view.html", link: function(h) { var c = window.Ares3 ? s.get("ares3NavItemProvider") : s.get("appNavItemProvider"),
                a = u.getCacheKey(u.keys.IsNewPerformanceReportEnabled, o.officeId),
                v = u.getCache(a),
                l = function() { var t, n, r;
                    v.saveValue(!0);
                    t = c.findNavItem("performance");
                    t.isVisible = !1;
                    n = c.findNavItem("performancev2");
                    n.isVisible = !0;
                    window.Ares3 ? (r = n.subItems[0], i.goToState(r.id)) : i.goToState("performancev2") },
                y = function() { i.goToState("setting.charge.paymentType") },
                p = function() { var n = [new i.TabItem("performance.chargeDetailView", "医生收费明细", "icon-bag", "performance.doctorChargeDetail"), new i.TabItem("performance.doctorApptView", "医生就诊人次", "icon-users", "performance.doctorVisits"), new i.TabItem("performance.nurseChargeDetailView", "护士收费明细", "icon-bag", "performance.nurseChargeDetail"), new i.TabItem("performance.nurseChargeCategoryView", "护士收费大类", "icon-calculator", "performance.nurseChargeCategroy"), new i.TabItem("performance.assistantReport", "牙医助理工作汇总", "icon-calculator", "performance.assistantWorkSummary"), new i.TabItem("performance.apptPerformanceView", "预约绩效查询", "icon-users", "performance.doctorApptPerformance"), new i.TabItem("performance.apptTransferredView", "转诊工作量", "icon-users", "performance.apptTransferred"), new i.TabItem("performance.chargeDeductionView", "执行划扣", "icon-users", "performance.chargeDeduction"), new i.TabItem("performance.networkConsult", "网电绩效", "icon-users", "performance.networkConsult"), new i.TabItem("performance.consultPerformanceView", "咨询师绩效", "icon-users", "performance.consultPerformanceView"), ];
                    h.isGroup ? n.splice(1, 0, new i.TabItem("performance.groupChargeCategoryView", "医生收费大类", "icon-calculator", "performance.doctorChargeCategroy")) : n.splice(1, 0, new i.TabItem("performance.chargeCategoryView", "医生收费大类", "icon-calculator", "performance.doctorChargeCategroy"));
                    e.isDelunCustomFeatureOpen() && n.push(new i.TabItem("performance.chargePlanpriceConfirmedView", "确认应收", "icon-users", "performance.chargeDeduction"));
                    b().then(function(t) { t && n.push(new i.TabItem("performance.medicalExamView", "拍片绩效", "icon-calculator", "performance.medicalExam"));
                        f.getOfficeOption(f.optionKeys.EnableConsultantDiagnose).then(function(t) { t && (n.splice(5, 0, new i.TabItem("performance.consultantChargeCategoryView", "咨询师收费大类", "icon-calculator", "performance.consultantChargeCategory")), n.splice(6, 0, new i.TabItem("performance.consultantReport", "咨询师工作汇总", "icon-calculator", "performance.consultantWorkSummary")));
                            h.states = n;
                            w() }) }) },
                w = function() { let n = e.isForceNewReportEnabled();
                    (!n || window.Ares3) && f.getOfficeOptions([f.optionKeys.IsNewPaymentTypeEnabled, f.optionKeys.PaymentTypeUpgradeStatus, ]).then(function(n) { var u = n[0],
                            t = parseInt(n[1]),
                            i = u || e.isPaymentTypeUpgradeEnabled();
                        window.Ares3 && (i &= t === r.PaymentTypeUpgradeStatus.Finished || t === r.PaymentTypeUpgradeStatus.InitUpgraded);
                        i && (h.commands = [{ text: "切换到新版", className: "financev2SwitchBtn", commandType: r.CommandType.Button, onExecute: function() { l() } }]) }) },
                b = function() { var t = n.defer(); return f.getOfficeOption(f.optionKeys.IsMedicalExamOpen).then(function(n) { t.resolve(n) }).catch(function() { t.resolve(!1) }), t.promise };
            (function() { h.isGroup = o.isGroup;
                t.isForcingToNewReportPromise().then(function(n) { n && !window.Ares3 ? l() : p() });
                h.navToPaymentTypeConfig = y })() } } }]);
managementModule.directive("performanceNetworkConsultView", ["$log", "$timeout", "$window", "$q", "appNav", "dataDicSvc", "practiceSvc", "reportSvc", "patientSvc", "localCache", "sessionCache", "gridOptionUtil", "permissionProvider", "reportUtil", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v) { return { restrict: "E", templateUrl: "/app/management/views/performance-network-consult-view.html", controller: "PerformanceNetworkConsultCtrl", link: function(n, r) { var e, f, o = c.getCache(c.keys.PageSize),
                s = 10;
            n.timeSpan = {};
            n.searchText = "";
            n.selectDate = "day"; var et = function() { var n = this.items();
                    $(n).each(function() { var n = $(this).find(".row-number");
                        $(n).html($(this).index() + 1) }) },
                u = "text-align: center; font-size: 14px; font-weight: bolder;",
                k = [{ field: "sequenceNum", title: "序号", sortable: !1, width: "80px", attributes: { style: "padding: 0" }, headerAttributes: { style: u }, footerTemplate: "总计" }, { field: "providerName", sortable: !1, title: "网电姓名", width: "140px", headerAttributes: { style: u } }, { field: "providerEmployeeNo", sortable: !1, title: "员工号", width: "100px", headerAttributes: { style: u } }, { field: "startDateStr", sortable: !1, title: "开始日期", width: "170px", headerAttributes: { style: u } }, { field: "endDateStr", sortable: !1, title: "结束日期", width: "170px", headerAttributes: { style: u } }, { field: "createdPatientCount", sortable: !1, title: "新建患者", width: "120px", headerAttributes: { style: u }, attributes: { "class": "column-template-default-style patient-count" }, aggregates: ["sum"], footerTemplate: "#=sum#" }, { field: "noApptCount", sortable: !1, title: "新建待预约", width: "120px", headerAttributes: { style: u }, attributes: { "class": "column-template-default-style app-pre-count" }, aggregates: ["sum"], footerTemplate: "#=sum#" }, { field: "createdApptCount", sortable: !1, title: "新建预约", width: "120px", headerAttributes: { style: u }, attributes: { "class": "column-template-default-style app-count" }, aggregates: ["sum"], footerTemplate: "#=sum#" }, { field: "createdConsultCount", sortable: !1, title: "新建咨询", width: "120px", headerAttributes: { style: u }, aggregates: ["sum"], footerTemplate: "#=sum#" }, { field: "createdRevisitCount", sortable: !1, title: "新建回访", width: "120px", headerAttributes: { style: u }, aggregates: ["sum"], footerTemplate: "#=sum#" }, { field: "actualPrice", sortable: !1, title: "消费金额", width: "180px", format: "{0:n}", headerAttributes: { style: u }, attributes: { "class": "column-template-default-style actual-price" }, aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }, { field: "performance", sortable: !1, title: "绩效收入", width: "180px", format: "{0:n}", headerAttributes: { style: u }, aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }, { field: "rechargeAmount", sortable: !1, title: "充值金额", width: "140px", format: "{0:n}", headerAttributes: { style: u }, aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }],
                d = function() { var n; if (o && (n = o.loadObject(), s = n.pageSize), !s) { var t = $(window).height(),
                            i = t - 240,
                            r = i - 81;
                        s = Math.max(5, parseInt(r / 30)) } },
                g = function() { if (n.pageData) { n.aggregate = [{ field: "createdPatientCount", aggregate: "sum" }, { field: "noApptCount", aggregate: "sum" }, { field: "createdApptCount", aggregate: "sum" }, { field: "createdConsultCount", aggregate: "sum" }, { field: "createdRevisitCount", aggregate: "sum" }, { field: "rechargeAmount", aggregate: "sum" }, { field: "actualPrice", aggregate: "sum" }, { field: "performance", aggregate: "sum" }];
                        d();
                        e = r.find("#networkConsultList"); var t = e.offset().top,
                            u = i.innerHeight - t - 10;
                        e.html("");
                        f = e.kendoGrid({ excel: { allPages: !0 }, excelExport: function(n) { var t = new Date,
                                    s = t.getFullYear(),
                                    i = (t.getMonth() + 1).toString(),
                                    r = t.getDate().toString(),
                                    o;
                                i.length == 1 && (i = "0" + i);
                                r.length == 1 && (r = "0" + r); var h = s + i + r,
                                    u = t.getHours().toString(),
                                    f = t.getMinutes().toString(),
                                    e = t.getSeconds().toString();
                                u.length == 1 && (u = "0" + u);
                                f.length == 1 && (f = "0" + f);
                                e.length == 1 && (e = "0" + e);
                                o = u + f + e;
                                n.workbook.fileName = "网电绩效_" + h + "_" + o + ".xls" }, dataSource: { data: n.pageData, aggregate: n.aggregate }, pageable: l.getPageable(s), scrollable: !0, columnMenu: !0, height: u, sortable: !0, resizable: !0, reorderable: !0, selectable: "single", model: { id: "id" }, columns: k, columnShow: function(n) { Ares.DockGridColMenuPos(n.sender) }, columnHide: function(n) { Ares.DockGridColMenuPos(n.sender) }, columnReorder: function(n) { Ares.DockGridColMenuPos(n.sender) }, dataBound: function(n) { Ares.DockGridColMenuPos(n.sender) } }).data("kendoGrid");
                        f.table.on("click", ".patient-count", y);
                        f.table.on("click", ".app-pre-count", p);
                        f.table.on("click", ".app-count", w);
                        f.table.on("click", ".actual-price", b) } },
                h = function(n) { var t = r.find("#networkConsultList").data("kendoGrid"); return t.dataItem(n) },
                y = function() { var t = $(this).closest("tr"),
                        i = h(t);
                    n.showDetail(i.providerId, 0) },
                p = function() { var t = $(this).closest("tr"),
                        i = h(t);
                    n.showDetail(i.providerId, 1) },
                w = function() { var t = $(this).closest("tr"),
                        i = h(t);
                    n.showDetail(i.providerId, 2) },
                b = function() { var t = $(this).closest("tr"),
                        i = h(t);
                    n.showDetail(i.providerId, 5) };
            n.exportExcel = function() { f && f.saveAsExcel() }; var nt = function(t) { var i = window.event ? t.keyCode : t.which;
                    i == 13 && n.search() },
                tt = function() { t(function() { var n = r.find("#networkConsultList").data("kendoGrid"),
                            t;
                        n && (t = n.pager, t && t.element.bind("change", function() { var t = n.dataSource.pageSize();
                            o && o.saveObject({ pageSize: t }) })) }, 1e3) },
                it = function() { var t = Ares.today(),
                        i = moment(Ares.today()).startOf("month").toDate(),
                        r = { startDate: i, endDate: t };
                    n.timeSpan = _.clone(r) },
                rt = function(t) { t === "previous" ? (n.timeSpan.startDate = moment(n.timeSpan.startDate).add(-1, n.selectDate).toDate(), n.timeSpan.endDate = moment(n.timeSpan.endDate).add(-1, n.selectDate).toDate()) : t === "next" && (n.timeSpan.startDate = moment(n.timeSpan.startDate).add(1, n.selectDate).toDate(), n.timeSpan.endDate = moment(n.timeSpan.endDate).add(1, n.selectDate).toDate());
                    n.search() },
                ut = function(t) { r.find("#btnDay").attr("class", "btn btn-default"); var i = v.getDefaultTimeSpan(); switch (t) {
                        case "all":
                            n.timeSpan.startDate = null;
                            n.timeSpan.endDate = null;
                            n.selectDate = "all"; break;
                        case "day":
                            n.timeSpan.startDate = moment(Ares.today()).toDate();
                            n.timeSpan.endDate = moment(Ares.today()).add(1).toDate();
                            n.selectDate = "day"; break;
                        case "week":
                            n.timeSpan.startDate = moment(Ares.today()).startOf("week").toDate();
                            n.timeSpan.endDate = moment(Ares.today()).endOf("week").toDate();
                            n.selectDate = "week"; break;
                        case "month":
                            n.timeSpan.startDate = i.startTime;
                            n.timeSpan.endDate = i.endTime;
                            n.selectDate = "month"; break;
                        case "custom":
                            n.timeSpan.endDate || it();
                            n.selectDate = "custom" } n.search() },
                ft = function() { n.timeSpan.startDate = moment(Ares.today()).toDate();
                    n.timeSpan.endDate = moment(Ares.today()).add(1).toDate();
                    n.search() };
            (function() { n.showPatientDetail = y;
                n.showAppPreDetail = p;
                n.showAppDetail = w;
                n.showActualPriceDetail = b;
                n.switchDate = ut;
                n.updateDate = rt;
                n.isAllowExportConsults = a.isAllowed("performance.networkConsultExcel");
                n.searchInputKeyup = nt;
                ft();
                n.$watch("pageData", function() { g();
                    tt() }) })() } } }]);
managementModule.directive("scheduleDoctorView", ["$log", "$modal", "$filter", "practiceSvc", "dataDicSvc", "aresDialog", "permissionProvider", "loginContext", function(n, t, i, r, u, f, e, o) { "use strict"; return { restrict: "E", replace: !0, controller: "ScheduleDoctorCtrl", templateUrl: "/app/management/views/schedule-doctor-view.html", scope: { officeId: "=" }, link: function(n, t) { var i = !1,
                e, s, h;
            n.selectedColIndex = -1;
            n.selectedRowIndex = -1;
            n.ruleDetailList = {};
            n.allRuleDetailList = {};
            n.originalDoctorScheduleList = {};
            e = function() { r.listScheduleRulesDetail("SHIFT").success(function(t) { t.push({ id: -1, name: "休息", startTime: moment(Ares.today()).format("YYYY-MM-DD 00:00"), endTime: moment(Ares.today()).format("YYYY-MM-DD 00:00"), scheduleColor: "#a9a9a9" });
                    n.ruleDetailList = t }) };
            s = function() { r.getAllScheduleRuleDetail().success(function(t) { t.push({ id: -1, name: "休息", startTime: moment(Ares.today()).format("YYYY-MM-DD 00:00"), endTime: moment(Ares.today()).format("YYYY-MM-DD 00:00"), scheduleColor: "#a9a9a9" });
                    n.allRuleDetailList = t }) };
            n.copyLastWeekRuleDetail = function() { n.searchCriteria && f.confirm("提示", "复制操作会先清除诊所的本周排班，确定要进行复制？").then(function() { var t = { startDate: moment(n.weekdays[0]).add("days", -7).format("YYYY-MM-DD 00:00"), endDate: moment(n.weekdays[6]).add("days", -7).format("YYYY-MM-DD 00:00") };
                    r.copySchedules(t).success(function() { var t, i; if (n.getWeekSchedule(), n.showDepartment) { if (t = $("#department").data("kendoDropDownList"), !t) return;
                            t.select(0);
                            i = t.text();
                            n.filterDepartment(i, !1) } }) }) };
            n.weekDays = [{ itemName: "星期一", itemValue: "1" }, { itemName: "星期二", itemValue: "2" }, { itemName: "星期三", itemValue: "3" }, { itemName: "星期四", itemValue: "4" }, { itemName: "星期五", itemValue: "5" }, { itemName: "星期六", itemValue: "6" }, { itemName: "星期日", itemValue: "7" }];
            n.navigate = function(t) { if (n.searchCriteria && (n.searchCriteria.selectDate = moment(n.searchCriteria.selectDate).add("days", t).format("YYYY/MM/DD"), n.scheduleWeekChange(), n.showDepartment)) { var i = $("#department").data("kendoDropDownList"); if (!i) return;
                    i.select(0) } };
            n.caculateWeekRange = function() { var i, r, t; if (n.searchCriteria)
                    for (i = moment(n.searchCriteria.selectDate).format("E"), r = 7 - i, n.searchCriteria.weekEndDate = moment(n.searchCriteria.selectDate).add("days", r), n.searchCriteria.weekStartDate = moment(n.searchCriteria.selectDate).add("days", -(i - 1)), n.weekdays = [], n.weekdays.push(n.searchCriteria.weekStartDate.toDate()), t = 1; t < 7; ++t) n.weekdays.push(moment(n.searchCriteria.weekStartDate).add("days", t).toDate()) };
            n.scheduleWeekChange = function() { var t, u, r; if (n.caculateWeekRange(), n.weekdays && n.weekdays.length == 7) { for (n.startDate = n.weekdays[0], n.endDate = n.weekdays[6], n.gridColumns = {}, n.gridColumns = [{ field: "officeName", title: "所属诊所", width: "150px", headerAttributes: { style: "text-align: center; font-size: 14px; font-weight: bolder;" } }, { field: "providerName", title: "医生", width: "150px", headerAttributes: { style: "text-align: center; font-size: 14px; font-weight: bolder;" } }], t = 0; t < n.weekdays.length; ++t) u = "column" + t, n.gridColumns.push({ title: moment(n.weekdays[t]).format("YYYY-MM-DD"), columns: [{ field: u, title: n.weekDays[t].itemName, headerAttributes: { style: "text-align: center; font-size: 14px; font-weight: bolder;" }, width: "100px" }], headerAttributes: { style: "text-align: center; font-size: 14px; font-weight: bolder;" } }); if (i = !1, n.getWeekSchedule(), n.showDepartment) { if (r = $("#department").data("kendoDropDownList"), !r) return;
                        r.select(0) } $("#scheduleList").empty() } }; var c = function(t) { var i; if (!(n.selectedRowIndex < 0) && !(n.selectedColIndex < 1) && n.doctorScheduleList) { var u = n.doctorScheduleList[n.selectedRowIndex],
                            s = "column" + (n.selectedColIndex - 2),
                            e = "idcolumn" + (n.selectedColIndex - 2),
                            h = "officeIdcolumn" + (n.selectedColIndex - 2),
                            c = n.weekdays[n.selectedColIndex - 2]; if (u[e] == 0) i = {}, i.id = 0, i.providerName = u.providerName, i.providerId = u.providerId, i.status = t.name, i.applyDate = moment(c).format("YYYY-MM-DD HH:mm"), i.scheduleRuleId = 0, i.scheduleRuleDetailId = t.id, i.startTime = t.startTime, i.endTime = t.endTime, r.createSchedule(i).success(function(t) { u[s] = t.status;
                            u[e] = t.id;
                            u[h] = o.officeId; var i = $("#scheduleList").data("kendoGrid");
                            i.dataSource.data(n.doctorScheduleList);
                            i.refresh() }).error(function(n) { n.name === "ScheduleConflictException" && f.info("提示", "该员工在该时间段已在其他诊所排班！") });
                        else { if (u[h] != o.officeId) { f.info("信息", "无法修改此员工在其他诊所的排班!"); return } i = {};
                            i.id = u[e];
                            i.providerName = u.providerName;
                            i.providerId = u.providerId;
                            i.status = t.name;
                            i.applyDate = moment(c).format("YYYY-MM-DD HH:mm");
                            i.scheduleRuleId = 0;
                            i.scheduleRuleDetailId = t.id;
                            i.startTime = t.startTime;
                            i.endTime = t.endTime;
                            r.updateSchedule(i).success(function() { u[s] = t.name; var i = $("#scheduleList").data("kendoGrid");
                                i.dataSource.data(n.doctorScheduleList);
                                i.refresh() }) } } },
                l = function() { if (!(n.selectedRowIndex < 0) && !(n.selectedColIndex < 1) && n.doctorScheduleList) { var t = n.doctorScheduleList[n.selectedRowIndex],
                            e = "column" + (n.selectedColIndex - 2),
                            i = "idcolumn" + (n.selectedColIndex - 2),
                            u = "officeIdcolumn" + (n.selectedColIndex - 2); if (t[i] != 0) { if (t[u] != o.officeId) { f.info("信息", "无法修改此员工在其他诊所的排班!"); return } r.deleteSchedule(t[i]).success(function() { t[e] = "";
                                t[i] = 0;
                                t[u] = 0; var r = $("#scheduleList").data("kendoGrid");
                                r.dataSource.data(n.doctorScheduleList);
                                r.refresh() }) } } },
                a = function() { var n = $("#scheduleList").data("kendoGrid");
                    n && n.saveAsExcel() };
            n.filterDepartment = function(t, i) { if (t == "全部") i ? n.$apply(n.doctorScheduleList = n.originalDoctorScheduleList) : n.doctorScheduleList = n.originalDoctorScheduleList;
                else { var r = []; if (!n.originalDoctorScheduleList) return;
                    _.each(n.originalDoctorScheduleList, function(n) { n.department == t && r.push(n) });
                    i ? n.$apply(n.doctorScheduleList = r) : n.doctorScheduleList = r } };
            h = function() { var r, f, u; if (!i) { i = !0;
                    r = t.find("#scheduleList");
                    f = $(window).height() - 180;
                    r.kendoGrid({ dataSource: { data: n.doctorScheduleList }, height: f, scrollable: !1, sortable: !1, selectable: "cell", columns: n.gridColumns, dataBound: function(t) { for (var e, u, i, r, a = t, v = t.sender.columns, h = t.sender.tbody.children(), f = 0; f < h.length; f++)
                                for (e = $(h[f]), u = t.sender.dataItem(e), i = 0; i < n.weekdays.length; ++i) { var l = "column" + i,
                                        c = "officeIdcolumn" + i,
                                        s = e.children().eq(i + 2); for (r = 0; r < n.allRuleDetailList.length; ++r) n.allRuleDetailList[r].name == u[l] && s.css("background-color", n.allRuleDetailList[r].scheduleColor);
                                    u[c] > 0 && u[c] != o.officeId && (s.css("background-image", 'url("images/warning1.png")'), s.css("background-repeat", "no-repeat")) } } });
                    u = r.data("kendoGrid");
                    $(u.tbody).on("click", "td", function() { var t = $(this).closest("tr");
                        n.selectedRowIndex = $("tr", u.tbody).index(t);
                        n.selectedColIndex = $("td", t).index(this); var i = n.doctorScheduleList[n.selectedRowIndex],
                            r = "column" + (n.selectedColIndex - 2),
                            f = "idcolumn" + (n.selectedColIndex - 2),
                            e = "officeIdcolumn" + (n.selectedColIndex - 2),
                            o = "otherName" + (n.selectedColIndex - 2),
                            s = "otherTime" + (n.selectedColIndex - 2),
                            h = "otherOfficeName" + (n.selectedColIndex - 2) }) } };
            n.getWeekSchedule = function() { var t = { startDate: moment(n.startDate).format("YYYY-MM-DD HH:mm"), endDate: moment(n.endDate).format("YYYY-MM-DD HH:mm") };
                    r.getSchedules(t).success(function(t) { for (var b, k, i, r, l, h, c = [], f = 0; f < n.doctorList.length; ++f) { for (i = 0; i < n.office.length; i++) n.doctorList[f].officeId == n.office[i].id && (n.doctorList[f].officeName = n.office[i].abbreviation); for (r = {}, r.officeName = n.doctorList[f].officeName, r.providerName = n.doctorList[f].name, r.providerId = n.doctorList[f].id, r.department = n.doctorList[f].department, i = 0; i < n.weekdays.length; i++) { var a = "column" + i,
                                    p = "idcolumn" + i,
                                    w = "officeIdcolumn" + i;
                                r[a] = "";
                                r[p] = 0;
                                r[w] = 0 } c.push(r) } for (f = 0; f < t.length; ++f) { for (i = 0; i < n.office.length; i++) t[f].officeId == n.office[i].id && (t[f].officeName = n.office[i].name); var e = t[f],
                                v = moment(e.applyDate).date(),
                                y = moment(n.startDate).date(),
                                s = v - y; for (v < y && (b = moment(n.startDate).endOf("month").format("YYYY-MM-DD"), k = moment(b).date(), s = v + k - y), i = 0; i < c.length; ++i)
                                if (r = c[i], r.providerId == e.providerId) { var a = "column" + s,
                                        p = "idcolumn" + s,
                                        w = "officeIdcolumn" + s,
                                        g = "otherName" + s,
                                        d = "otherTime" + s,
                                        nt = "otherOfficeName" + s; if (r[a] = e.status, r[p] = e.id, r[w] = e.officeId, o.officeId != e.officeId)
                                        for (r[a] = e.officeName, r[g] = e.status, r[d] = moment(e.startTime).format("HH:mm") + "到" + moment(e.endTime).format("HH:mm"), e.status == "休息" && (r[d] = ""), l = u.officeDic.data(), h = 0; h < l.length; ++h)
                                            if (l[h].id == e.officeId) { r[nt] = l[h].name; break } break } } n.doctorScheduleList = c;
                        n.originalDoctorScheduleList = n.doctorScheduleList }) },
                function() { var f, t; for (e(), s(), f = u.systemsettingDic.data(), n.departements = [], n.doctorScheduleList = [], t = 0; t < f.length; ++t) f[t].itemType == "科室" && n.departements.push(f[t]);
                    n.showDepartment = n.departements.length > 0 ? !0 : !1;
                    $("#department").kendoDropDownList({ dataSource: n.departements, dataTextField: "itemName", dataValueField: "itemName", optionLabel: "全部", select: function(t) { var i = t.item[0].innerText;
                            n.filterDepartment(i, !0) } });
                    n.office = {};
                    r.listOffices().success(function(t) { n.office = t });
                    r.getDoctors().success(function(t) { n.doctorList = t;
                        n.setRuleDetail = c;
                        n.removeRuleDetail = l;
                        n.exportExcel = a;
                        n.searchCriteria = { selectDate: moment(Ares.today()).format("YYYY-MM-DD") };
                        n.scheduleWeekChange();
                        n.$watch("doctorScheduleList", function() { if (i) { var t = $("#scheduleList").data("kendoGrid");
                                t.dataSource.data(n.doctorScheduleList);
                                t.refresh() } else h() }) }) }() } } }]);
managementModule.directive("scheduleHomeView", ["$log", "$timeout", "$filter", "$window", "appNav", "enums", "permissionProvider", function(n, t, i, r, u) { "use strict"; return { restrict: "E", templateUrl: "/app/management/views/schedule-home-view.html", scope: { officeId: "=" }, link: function(n) { var t = function() { var t = [new u.TabItem("schedule.rulesetting", "排班规则", "icon-bag", "setting.schedule"), new u.TabItem("schedule.doctorSchedule", "诊所医生排班", "icon-calendar", "setting.schedule"), new u.TabItem("schedule.tenantSchedule", "公司排班浏览", "icon-film", "setting.schedule"), ];
                n.states = t };
            (function() { t();
                u.switchState("schedule.doctorSchedule") })() } } }]);
managementModule.directive("scheduleRulesettingDialog", ["$log", "$filter", function() { "use strict"; return { replace: !0, templateUrl: "/app/management/views/schedule-rulesetting-dialog.html", link: function(n) {
            (function() { $("#palette").kendoColorPicker({ columns: 2, tileSize: { width: 50, height: 30 }, palette: ["#FFD9D9", "#FFC2C2", "#FFAAAA", "#FF7C7C", "#FFE1BE", "#FFCD93", "#FFBF75", "#FFAF51", "#ACFDCE", "#62EC9B", "#A8F4E3", "#62E3C6", "#BEE3FF", "#8DCEFF", "#E5E2FF", "#FFF0A3", "#FFE663", "#E7FFB3", "#D7FF81"], change: function(t) { n.currentRuleDetail && (n.currentRuleDetail.scheduleColor = t.value) } }) })() } } }]);
managementModule.directive("scheduleRulesettingView", ["$log", "$modal", "$filter", "practiceSvc", "aresDialog", function(n, t, i, r, u) { "use strict"; return { restrict: "E", replace: !0, controller: "ScheduleRulesettingCtrl", templateUrl: "/app/management/views/schedule-rulesetting-view.html", scope: { officeId: "=" }, link: function(n, t) { var f = !1,
                i = function() { r.listScheduleRulesDetail("SHIFT").success(function(t) { for (var i = 0; i < t.length; ++i) t[i].startTimeStr = moment(t[i].startTime).format("HH:mm"), t[i].endTimeStr = moment(t[i].endTime).format("HH:mm"), t[i].isDefaultStr = t[i].isDefault != !0 ? "否" : "是";
                        n.ruleDetailList = t }) },
                e = function() { if (!n.isCreateRule) { var t = $("#ruleDetailList").data("kendoGrid");
                        t.cancelChanges();
                        t.addRow();
                        n.isCreateRule = !0 } },
                o = function() { var i = { "class": "table-header-cell", style: "text-align: center; font-weight: bolder" },
                        r, u;
                    n.ruleDetailList && (f = !0, r = function(t) { var r, u, f, i; if (t.is("[name=name]")) { if (r = t.val(), r == "") return t.attr("data-nameValidation-msg", "班次不能为空"), !1; if (u = $(t).closest("tr"), f = $("#ruleDetailList").data("kendoGrid").dataItem(u), n.ruleDetailList)
                                for (i = 0; i < n.ruleDetailList.length; ++i)
                                    if (n.ruleDetailList[i].name == r && n.ruleDetailList[i].id != f.id) return t.attr("data-nameValidation-msg", "名称已被使用，请改名"), !1 } return !0 }, u = t.find("#ruleDetailList"), u.kendoGrid({ dataSource: { data: n.ruleDetailList, schema: { model: { id: "id", fields: { id: { defaultValue: 0 }, name: { validation: { nameValidation: r } }, startTimeStr: { validation: { startTimeStrValidation: function(n) { if (n.is("[name=startTimeStr]")) { var t = n.data("kendoTimePicker").value(); if (!moment(t).isValid()) return n.attr("data-startTimeStrValidation-msg", "上班时间格式不正确"), !1 } return !0 } } }, endTimeStr: { validation: { endTimeStrValidation: function(n) { if (n.is("[name=endTimeStr]")) { var t = n.data("kendoTimePicker").value(); if (!moment(t).isValid()) return n.attr("data-endTimeStrValidation-msg", "下班时间格式不正确"), !1 } return !0 } } }, scheduleColor: { validation: { required: !0 }, defaultValue: "#FFD9D9" }, isDefaultStr: { defaultValue: "否" } } } } }, scrollable: !1, selectable: "single", editable: { mode: "inline", createAt: "bottom" }, columns: [{ field: "name", title: "班次", width: "150px", headerAttributes: i }, { field: "startTimeStr", title: "上班时间", width: "80px", headerAttributes: i, editor: function(n, t) { var i = $('<input name="' + t.field + '"/>'),
                                    r;
                                i.appendTo(n);
                                i.kendoTimePicker({ interval: 10 });
                                r = $('<span class="k-invalid-msg" data-for="' + t.field + '"><\/span>');
                                r.appendTo(n) } }, { field: "endTimeStr", title: "下班时间", width: "60px", headerAttributes: i, editor: function(n, t) { var i = $('<input name="' + t.field + '"/>'),
                                    r;
                                i.appendTo(n);
                                i.kendoTimePicker({ interval: 10 });
                                r = $('<span class="k-invalid-msg" data-for="' + t.field + '"><\/span>');
                                r.appendTo(n) } }, { field: "scheduleColor", title: "标示颜色", width: "80px", headerAttributes: i, attributes: { style: "background-color: #=scheduleColor#;" }, template: "", editor: function(n, t) { $(n).css("background-color", "inherit"); var i = $('<input name="' + t.field + '" type="color" />');
                                i.appendTo($(n));
                                i.kendoColorPicker({ tileSize: 32, palette: ["#FFD9D9", "#FFC2C2", "#FFAAAA", "#FF7C7C", "#FFE1BE", "#FFCD93", "#FFBF75", "#FFAF51", "#ACFDCE", "#62EC9B", "#A8F4E3", "#62E3C6", "#BEE3FF", "#8DCEFF", "#E5E2FF", "#FFF0A3", "#FFE663", "#E7FFB3", "#D7FF81", "#ffffff"] });
                                $(n).find(".k-selected-color").css({ width: "100%", height: "2.25em" }) } }, { field: "isDefaultStr", title: "诊所工作时间", width: "60px", headerAttributes: i, editor: function(n, t) { $(n).html(t.model.isDefaultStr) } }, { command: [{ name: "编辑", text: "编辑", click: n.editDetail, className: "fa fa-edit" }, { name: "更新", text: "更新", click: n.updateDetail, className: "fa fa-check hide" }, { name: "取消", text: "取消", click: n.cancelEdit, className: "fa fa-close hide" }, { name: "删除", text: "删除", click: n.deleteDetail, className: "fa fa-trash-o" }], title: "", width: "120px" }], edit: function(n) { n.container.find(".k-grid-编辑,.k-grid-删除").addClass("hide");
                            n.container.find(".k-grid-更新,.k-grid-取消").removeClass("hide") } })) };
            n.editDetail = function(t) { var i, r, u;
                (t.preventDefault(), n.isCreateRule = !1, i = $(t.currentTarget).closest("tr"), r = this.dataItem(i), r && r.id) && (u = $("#ruleDetailList").data("kendoGrid"), u.editRow(i)) };
            n.updateDetail = function(t) { var f, o; if (t.preventDefault(), f = $(t.currentTarget).closest("tr"), o = f.data("kendoValidator"), o.validate()) { var e = this.dataItem(f),
                        l = f.find("input[name='startTimeStr']").data("kendoTimePicker"),
                        a = f.find("input[name='endTimeStr']").data("kendoTimePicker"),
                        s = moment(l.value()),
                        h = moment(a.value()),
                        c = { ET: "2015-01-01T12:00:00.000Z", ST: "2015-01-01T00:00:00.000Z", endTime: h.format("HH:mm"), id: e.id, name: e.name, scheduleColor: e.scheduleColor, startTime: s.format("HH:mm"), status: "SHIFT", weekDayType: "AllWeekDays" }; if (s >= h) { u.info("信息", "上班时间必须早于下班时间！"); return } n.isCreateRule ? r.createScheduleRuleDetail(c).success(function() { n.showNotification("保存成功！");
                        n.isCreateRule = !1;
                        i() }) : r.updateScheduleRuleDetail(c).success(function() { n.showNotification("保存成功！");
                        i() }) } };
            n.cancelEdit = function(t) { t.preventDefault(); var i = $("#ruleDetailList").data("kendoGrid");
                i.cancelChanges();
                n.isCreateRule = !1 };
            n.deleteDetail = function(n) { n.preventDefault(); var t = this.dataItem($(n.currentTarget).closest("tr")); if (t && t.id) { if (t.isDefault == !0) { u.info("信息", "诊所工作时间配置不允许删除！"); return } u.confirm("删除", "如果删除班次规则，今后的排班记录均会被删除，确认删除？").then(function() { r.deleteScheduleRuleDetail(t.id).success(function() { i() }) }) } },
                function() { n.createRuleDetail = e;
                    i();
                    n.$watch("ruleDetailList", function() { if (f) { var t = $("#ruleDetailList").data("kendoGrid");
                            t.dataSource.data(n.ruleDetailList) } else o() }) }() } } }]);
managementModule.directive("scheduleTenantView", ["$log", "$modal", "$filter", "practiceSvc", "dataDicSvc", "aresDialog", "permissionProvider", "loginContext", function(n, t, i, r, u) { "use strict"; return { restrict: "E", replace: !0, controller: "ScheduleTenantCtrl", templateUrl: "/app/management/views/schedule-tenant-view.html", scope: { officeId: "=" }, link: function(n, t) { var i = !1,
                f, e, o;
            n.selectedColIndex = -1;
            n.selectedRowIndex = -1;
            n.ruleDetailList = {};
            f = function() { r.listScheduleRulesDetailByTenant("SHIFT").success(function(t) { t.push({ id: -1, name: "休息", startTime: moment(Ares.today()).format("YYYY-MM-DD 00:00"), endTime: moment(Ares.today()).format("YYYY-MM-DD 00:00"), scheduleColor: "#a9a9a9" });
                    n.ruleDetailList = t }) };
            n.weekDays = [{ itemName: "星期一", itemValue: "1" }, { itemName: "星期二", itemValue: "2" }, { itemName: "星期三", itemValue: "3" }, { itemName: "星期四", itemValue: "4" }, { itemName: "星期五", itemValue: "5" }, { itemName: "星期六", itemValue: "6" }, { itemName: "星期日", itemValue: "7" }];
            n.navigate = function(t) { n.searchCriteria && (n.searchCriteria.selectDate = moment(n.searchCriteria.selectDate).add("days", t).format("YYYY/MM/DD"), n.scheduleWeekChange()) };
            n.caculateWeekRange = function() { var i, r, t; if (n.searchCriteria)
                    for (i = moment(n.searchCriteria.selectDate).format("E"), r = 7 - i, n.searchCriteria.weekEndDate = moment(n.searchCriteria.selectDate).add("days", r), n.searchCriteria.weekStartDate = moment(n.searchCriteria.selectDate).add("days", -(i - 1)), n.weekdays = [], n.weekdays.push(n.searchCriteria.weekStartDate.toDate()), t = 1; t < 7; ++t) n.weekdays.push(moment(n.searchCriteria.weekStartDate).add("days", t).toDate()) };
            n.scheduleWeekChange = function() { var t, r; if (n.caculateWeekRange(), n.weekdays && n.weekdays.length == 7) { for (n.startDate = n.weekdays[0], n.endDate = n.weekdays[6], n.gridColumns = {}, n.gridColumns = [{ field: "officeName", title: "所属诊所", width: "150px", headerAttributes: { style: "text-align: center; font-size: 14px; font-weight: bolder;" } }, { field: "providerName", title: "医生", width: "150px", headerAttributes: { style: "text-align: center; font-size: 14px; font-weight: bolder;" } }], t = 0; t < n.weekdays.length; ++t) r = "column" + t, n.gridColumns.push({ title: moment(n.weekdays[t]).format("YYYY-MM-DD"), columns: [{ field: r, title: n.weekDays[t].itemName, headerAttributes: { style: "text-align: center; font-size: 14px; font-weight: bolder;" }, width: "100px" }], headerAttributes: { style: "text-align: center; font-size: 14px; font-weight: bolder;" } });
                    i = !1;
                    n.getWeekSchedule();
                    $("#scheduleList").empty() } };
            e = function() { var n = $("#scheduleList").data("kendoGrid");
                n && n.saveAsExcel() };
            o = function() { var r, u, f, e;
                i || (i = !0, r = t.find("#scheduleList"), u = $(window).height() - 180, r.kendoGrid({ dataSource: { data: n.doctorScheduleList }, height: u, scrollable: !0, selectable: "cell", columns: n.gridColumns, dataBound: function(t) { for (var f, o, i, r, c = t, l = t.sender.columns, e = t.sender.tbody.children(), u = 0; u < e.length; u++)
                            for (f = $(e[u]), o = t.sender.dataItem(f), i = 0; i < n.weekdays.length; ++i) { var a = "column" + i,
                                    v = "officeIdcolumn" + i,
                                    s = "idcolumnRule" + i,
                                    h = f.children().eq(i + 2); for (r = 0; r < n.ruleDetailList.length; ++r) n.ruleDetailList[r].id == o[s] && h.css("background-color", n.ruleDetailList[r].scheduleColor) } } }), f = { field: "officeName", dir: "desc" }, e = r.data("kendoGrid"), e.dataSource.sort(f)) };
            n.getWeekSchedule = function() { var t = { startDate: moment(n.startDate).format("YYYY-MM-DD HH:mm"), endDate: moment(n.endDate).format("YYYY-MM-DD HH:mm") };
                    r.getSchedules(t).success(function(t) { var a, c, l, r, v, y, d, i; for (n.officeScheduleList = [], a = u.officeDic.data(), c = 0; c < a.length; ++c) n.officeScheduleList.push({ officeId: a[c].id, officeName: a[c].abbreviation, doctorScheduleList: [] }); for (l = 0; l < t.length; ++l) { var f = t[l],
                                o = null,
                                p = null; for (i = 0; i < n.officeScheduleList.length; i++) t[l].officeId == n.officeScheduleList[i].officeId && (p = n.officeScheduleList[i].officeName); for (i = 0; i < n.doctorList.length; i++) f.providerId == n.doctorList[i].id && (f.officeId = n.doctorList[i].officeId); for (i = 0; i < n.officeScheduleList.length; ++i)
                                if (n.officeScheduleList[i].officeId == f.officeId) { o = n.officeScheduleList[i]; break } if (o != null) { for (r = null, i = 0; i < o.doctorScheduleList.length; ++i)
                                    if (o.doctorScheduleList[i].providerId == f.providerId) { r = o.doctorScheduleList[i]; break } if (r == null) { for (r = {}, r.officeName = o.officeName, r.providerName = f.providerName, r.providerId = f.providerId, i = 0; i < n.weekdays.length; i++) { var w = "column" + i,
                                            b = "idcolumn" + i,
                                            k = "idcolumnRule" + e;
                                        r[w] = "";
                                        r[b] = 0;
                                        r[k] = 0 } var s = moment(f.applyDate).date(),
                                        h = moment(n.startDate).date(),
                                        e = s - h;
                                    s < h && (v = moment(n.startDate).endOf("month").format("YYYY-MM-DD"), y = moment(v).date(), e = s + y - h); var w = "column" + e,
                                        b = "idcolumn" + e,
                                        k = "idcolumnRule" + e;
                                    r[w] = p + ":" + f.status;
                                    r[b] = f.id;
                                    r[k] = f.scheduleRuleDetailId;
                                    o.doctorScheduleList.push(r) } else { var s = moment(f.applyDate).date(),
                                        h = moment(n.startDate).date(),
                                        e = s - h;
                                    s < h && (v = moment(n.startDate).endOf("month").format("YYYY-MM-DD"), y = moment(v).date(), e = s + y - h); var w = "column" + e,
                                        b = "idcolumn" + e,
                                        k = "idcolumnRule" + e;
                                    r[w] = p + ":" + f.status;
                                    r[b] = f.id;
                                    r[k] = f.scheduleRuleDetailId } } } for (d = [], i = 0; i < n.officeScheduleList.length; ++i) _.each(n.officeScheduleList[i].doctorScheduleList, function(n) { d.push(n) });
                        n.doctorScheduleList = d }) },
                function() { f();
                    n.office = {};
                    r.listOffices().success(function(t) { n.office = t });
                    r.getDoctors().success(function(t) { n.doctorList = t;
                        n.exportExcel = e;
                        n.searchCriteria = { selectDate: moment(Ares.today()).format("YYYY-MM-DD") };
                        n.scheduleWeekChange();
                        n.$watch("doctorScheduleList", function() { if (i) { var t = $("#scheduleList").data("kendoGrid");
                                t.dataSource.data(n.doctorScheduleList);
                                t.refresh() } else o() }) }) }() } } }]);
managementModule.directive("complaintHomeView", ["$log", "appNav", "$modal", function(n, t, i) { "use strict"; return { restrict: "E", templateUrl: "/app/management/views/complaint/complaint-home-view.html", link: function(n) { var r = function() { n.commands = [new Ares.TabCommand("新增投诉", u, "lc-btn lc-btn-orange lc-btn-icon")] },
                u = function() { var n = i.open({ animation: !0, backdrop: "static", template: "<complaint-edit-view><\/complaint-edit-view>", controller: "ComplaintEditCtrl", backdropClass: "ares-modal-backdrop", resolve: { host: function() { return { type: "add" } } } }) },
                f = function() { var i = [new t.TabItem("complaint.list", "投诉管理", "", "")];
                    n.states = i };
            (function() { r();
                f() })() } } }]);
managementModule.directive("complaintListView", ["$log", "$window", "$modal", "$timeout", "$q", "kendoUtil", "practiceSvc", function(n, t, i, r, u, f, e) { "use strict"; return { templateUrl: "/app/management/views/complaint/complaint-list-view.html", controller: "ComplaintListCtrl", link: function(n, u) { var s, h, c, l, a, v, y, p = [{ name: "全部状态", value: null }, { name: "待处理", value: 1 }, { name: "已处理", value: 2 }, { name: "已反馈", value: 3 }],
                w = [{ name: "严重程度", value: null }, { name: "低", value: 1 }, { name: "中", value: 2 }, { name: "高", value: 3 }],
                g = function() { a = u.find("#providerType").kendoDropDownList({ dataSource: [{ name: "受理员工", value: 1 }, { name: "处理员工", value: 2 }, { name: "反馈员工", value: 3 }], dataTextField: "name", dataValueField: "value", select: function(t) { var i = this;
                            r(function() { n.providerType = i.dataItem(t.item)[i.options.dataValueField] }) } }).data("kendoDropDownList") },
                nt = function() { v = u.find("#provider").kendoDropDownList({ dataSource: n.providers, filter: "contains", dataTextField: "name", dataValueField: "id", optionLabel: "全部", value: n.providerId || null, select: function(t) { n.providerId = this.dataItem(t.item)[this.options.dataValueField] || null } }).data("kendoDropDownList") },
                tt = function() { h = u.find("#timeStatus").kendoDropDownList({ dataSource: [{ name: "受理时间", value: 1 }, { name: "处理时间", value: 2 }, { name: "反馈时间", value: 3 }], dataTextField: "name", dataValueField: "value", select: function(t) { var i = this;
                            r(function() { n.timeStatus = i.dataItem(t.item)[i.options.dataValueField] }) } }).data("kendoDropDownList") },
                it = function() { s = u.find("#complaintState").kendoDropDownList({ dataSource: p, dataTextField: "name", dataValueField: "value", select: function(t) { var i = this;
                            r(function() { n.complaintStates = i.dataItem(t.item)[i.options.dataValueField] }) } }).data("kendoDropDownList") },
                rt = function() { e.getItemTypes(n.itemType).success(function(t) { var i = u.find("#category");
                        c = i.kendoDropDownList({ dataSource: t, dataTextField: "itemName", dataValueField: "itemName", optionLabel: "全部主题", select: function(t) { n.category = this.dataItem(t.item)[this.options.dataValueField] || null } }).data("kendoDropDownList") }) },
                ut = function() { l = u.find("#severity").kendoDropDownList({ dataSource: w, dataTextField: "name", dataValueField: "value", select: function(t) { var i = this;
                            r(function() { n.severity = i.dataItem(t.item)[i.options.dataValueField] }) } }).data("kendoDropDownList") },
                ft = function() { y = u.find("#satisfaction").kendoDropDownList({ dataSource: [{ name: "满意度", value: null }, { name: "满意", value: 1 }, { name: "不满意", value: 2 }], dataTextField: "name", dataValueField: "value", select: function(t) { var i = this;
                            r(function() { n.satisfaction = i.dataItem(t.item)[i.options.dataValueField] }) } }).data("kendoDropDownList") },
                et = [{ field: "state", title: "状态", width: "60px", locked: !0, template: function(n) { var t = n.state,
                            i = _.find(p, function(n) { return n.value == t }) || ""; return '<span class="complaint-status-' + t + '">' + i.name + "<\/span>" } }, { field: "severity", title: "严重程度", width: "85px", template: function(n) { var i = n.severity,
                            t = _.find(w, function(n) { return n.value == i }); return t ? t.name : "" } }, { field: "satisfaction", title: "满意度", width: "85px", template: function(n) { var i = n.satisfaction,
                            t = ""; return i == 1 ? t = "满意" : i == 2 && (t = "不满意"), t } }, { field: "sourcePatientName", title: "投诉人", width: "85px" }, { field: "targetProvideName", title: "被投诉人", width: "85px" }, { field: "category", title: "投诉主题", width: "85px" }, { field: "content", title: "投诉内容", width: "130px" }, { field: "processResult", title: "投诉处理", width: "130px" }, { field: "feedbackContent", title: "投诉反馈", width: "110px" }, { field: "recordProviderName", title: "受理员工", width: "110px" }, { field: "processProviderName", title: "处理员工", width: "110px" }, { field: "feedbackProviderName", title: "反馈员工", width: "110px" }, { field: "recordTime", title: "受理时间", width: "110px", template: function(n) { return f.datetimeFormat(n.recordTime) } }, { field: "processTime", title: "处理时间", width: "110px", template: function(n) { return f.datetimeFormat(n.processTime) } }, { field: "feedbackTime", title: "反馈时间", width: "110px", template: function(n) { return f.datetimeFormat(n.feedbackTime) } }, { field: "", title: "操作", width: "60px", template: function(n) { var u = n.id,
                            r = n.state,
                            t = "",
                            i = ""; return r == 1 ? (t = "处理", i = "process") : r == 2 ? (t = "反馈", i = "feedback") : r == 3 && (t = "查看", i = "detail"), '<span class="enyo-text-primary edit-button" dataId="' + u + '" state="' + i + '">' + t + "<\/span>" } }, ],
                b = null,
                o = function(i) { n.refreshListData(i).then(function(n) { var i, r, f;
                        b = angular.copy(et);
                        i = u.find("#complaintListGrid");
                        i.html("");
                        r = t.innerHeight - 210 - (window.Ares3 ? 20 : 0);
                        f = i.kendoGrid({ excel: { allPages: !0 }, dataSource: { data: n.items }, height: r, model: { id: "id" }, columns: b, sortable: !1, resizable: !0, reorderable: !0, columnMenu: !1, columnMenuInit: function(n) { n.container.find(".k-sort-asc").remove();
                                n.container.find(".k-sort-desc").remove(); var t = $(n.container).find(".k-menu-group");
                                t.find("li").each(function(n, t) { var i = $(t).text();
                                    i == " " && $(t).remove() }) } }).data("kendoGrid");
                        f.table.on("click", ".edit-button", ct) }) },
                ot = function(t) { n.pageIndex = t;
                    o() },
                st = function(t) { n.pageSize = t;
                    o() },
                ht = function() { tt();
                    it();
                    rt();
                    ut();
                    d();
                    g();
                    ft();
                    n.initProviders().then(function() { nt() });
                    n.timeStatus = 1;
                    n.providerType = 1;
                    o(!1) },
                ct = function() { var n = $(this).attr("dataId"),
                        t = $(this).attr("state");
                    at(n, t) },
                lt = function() { n.complaintStates = null;
                    n.timeStatus = 1;
                    n.satisfaction = null;
                    n.category = null;
                    n.severity = null;
                    n.providerType = 1;
                    n.providerId = null;
                    s.value(null);
                    h.value(1);
                    c.value(null);
                    l.value(null);
                    a.value(1);
                    v.value(null);
                    y.value(null);
                    o(1) },
                k = function() { o(1) },
                at = function(n, t) { var r = i.open({ animation: !0, backdrop: "static", template: "<complaint-edit-view><\/complaint-edit-view>", controller: "ComplaintEditCtrl", backdropClass: "ares-modal-backdrop", resolve: { host: function() { return { complaintId: n, type: t } } } });
                    r.result.then(function(n) { n && k() }) },
                d = function() { var t = moment().format("YYYY-MM-DD"),
                        i = moment().add(1, "day").format("YYYY-MM-DD");
                    n.startTime = t;
                    n.endTime = moment(i).add(1, "day").format("YYYY-MM-DD");
                    n.timeSpan = { startDate: t, endDate: i } },
                vt = function(t) { t = t || n.timeSpan;
                    n.startTime = moment(t.startDate).format("YYYY-MM-DD");
                    n.endTime = moment(t.endDate).add(1, "day").format("YYYY-MM-DD") };
            (function() { n.onPageChanged = ot;
                n.onPageSizeChanged = st;
                n.refresh = lt;
                n.search = k;
                n.initTimeSpan = d;
                n.onDateRangeChanged = vt;
                n.itemType = "投诉主题";
                ht() })() } } }]);
managementModule.directive("consultHomeView", ["$log", "$timeout", "$filter", "$window", "appNav", "enums", "loginContext", "permissionProvider", "systemConfigUtil", function(n, t, i, r, u) { "use strict"; return { restrict: "E", templateUrl: "/app/management/views/consult/consult-home-view.html", link: function(n) { var t = function() { var t = [new u.TabItem("consultCenter.list", "现场咨询", "icon-users", "consultCenter.list"), new u.TabItem("consultCenter.networkList", "网电咨询", "icon-users", "consultCenter.consultList"), new u.TabItem("consultCenter.sceneConsultList", "现场咨询任务列表", "icon-users", "consultCenter.list"), new u.TabItem("consultCenter.intention", "成交意愿", "icon-users", "consultCenter.willingParties"), ];
                n.states = t };
            (function() { t() })() } } }]);
managementModule.directive("consultIntentionEditView", ["$log", "$timeout", "dataDicSvc", function(n, t) { "use strict"; return { replace: !0, templateUrl: "/app/management/views/consult/consult-intention-edit-view.html", link: function(n, i) { var r, u = function() { r = Ares.validateForm(i.find("#ruleSettingForm"), { itemName: { required: !0, systemItemName: !0, maxlength: 20 } }, { itemName: { required: "请输入项目名称", systemItemName: "名称已被使用", maxlength: "项目名称不能超过20个字符" } }) },
                f = function() { i.find("#ruleSettingForm").valid() && n.saveSystemItem() },
                e = function() { jQuery.validator.addMethod("systemItemName", function(t) { var i = !0,
                            r; return t && (r = _.some(n.siblings, function(t) { return t.itemName === n.currentSystemItem.itemName && t.id !== n.currentSystemItem.id }), r && (i = !1)), i }, "名称已被使用！") };
            (function() { e();
                u();
                n.validAndSave = f;
                n.$watch("currentSystemItem", function() { r && Ares.clearError(i.find("#ruleSettingForm")) });
                t(function() { Ares.centerModal(i.closest(".modal-dialog")) }, 5) })() } } }]);
managementModule.directive("consultIntentionView", ["$log", "$q", "$timeout", "$filter", "$modal", "appNav", "aresDialog", "moduleUtil", "$injector", "dataDicSvc", "permissionProvider", "loginContext", function() { "use strict"; return { restrict: "E", replace: !0, controller: "consultIntentionCtrl", templateUrl: "/app/management/views/consult/consult-intention-view.html", link: function(n, t) { var i = null,
                r = function() { if (n.intentions) { var r = $(t).find("#consultIntentionList");
                        i = r.kendoGrid({ dataSource: { data: n.intentions }, scrollable: !1, sortable: !0, selectable: "single", change: function() { var t = this.dataItem(this.select());
                                n.$apply(function() { n.selectedItem = t ? t : null }) }, columns: [{ field: "itemName", title: "名称", width: "100px", attributes: { "class": "cell-left" } }, ] }).data("kendoGrid") } },
                u = function() { var f, u, e;
                    i ? (i.dataSource.data(n.intentions), n.selectedItem && (f = i.dataSource, u = f.get(n.selectedItem.id), u && (e = t.find("#consultIntentionList").find("tbody>tr[data-uid=" + u.uid + "]"), i.select(e)), n.selectedItem = u)) : r() };
            (function() { n.$watch("intentions", function() { u() }) })() } } }]);
managementModule.directive("consultListView", ["$log", "$q", "$timeout", "$filter", "$modal", "appNav", "aresDialog", "moduleUtil", "$injector", "dataDicSvc", "permissionProvider", "loginContext", function(n, t, i, r, u, f, e, o, s, h, c) { "use strict"; return { restrict: "E", replace: !0, controller: "consultListCtrl", templateUrl: "/app/management/views/consult/consult-list-view.html", link: function(n, t) { var o = function() { var n = $(window).height() - 270;
                    t.find("#list-body").css("height", n);
                    i(function() { var n = t.find(".action-icon-btn");
                        n.tooltip() }, 100) },
                s = function() { h.systemItemDic.loadActive({ itemType: "成交意愿" }).then(function(i) { i.unshift({ itemName: "全部", id: -1 }); var r = t.find("#consultIntentionInput");
                        r.kendoDropDownList({ dataSource: i, dataTextField: "itemName", dataValueField: "itemName", value: n.searchCriteria.intention, select: function(t) { var i = this.dataItem(t.item.index());
                                i.itemName == "全部" && (i.id = "");
                                n.searchCriteria.intention = i.id;
                                Ares.sensors.trackDropDownEvent("ConsultList", "成交意愿") } }) }) },
                r = function() { var i = t.find("#consultStateInput");
                    i.kendoDropDownList({ dataSource: [{ id: "", itemName: "全部" }, { id: "未成交", itemName: "未成交" }, { id: "已成交", itemName: "已成交" }], dataTextField: "itemName", dataValueField: "id", value: n.searchCriteria.state, select: function(t) { var i = this.dataItem(t.item.index());
                            n.searchCriteria.state = i.id;
                            Ares.sensors.trackDropDownEvent("ConsultList", "成交状态") } }) },
                u = function() { h.systemsettingDic.loadActive().then(function(i) { var r = _.filter(i, function(n) { return n.itemType == "就诊类型" }),
                            u;
                        r.unshift({ itemName: "全部" });
                        u = t.find("#visitStateInput");
                        u.kendoDropDownList({ dataSource: r, dataTextField: "itemName", dataValueField: "itemName", value: n.searchCriteria.checkInType, select: function(t) { var i = this.dataItem(t.item.index());
                                n.searchCriteria.checkInType = i.itemName == "全部" ? null : i.itemName;
                                Ares.sensors.trackDropDownEvent("ConsultList", "就诊类型") } }) }) },
                e = function() { h.consultantDic.loadActive().then(function(r) { r.unshift({ name: "全部", id: -1 });
                        i(function() { var i = t.find("#consultantInput");
                            i.kendoDropDownList({ filter: "contains", placeholder: "请选择咨询师", dataSource: r, dataTextField: "name", dataValueField: "id", select: function(t) { n.searchCriteria.consultantId = this.dataItem(t.item)[this.options.dataValueField] || null;
                                    Ares.sensors.trackDropDownEvent("ConsultList", "咨询师") } }) }) }) },
                l = function() { h.consultItemDic.loadActive().then(function(r) { r.unshift({ itemName: "全部" });
                        i(function() { var i = t.find("#consultItemInput");
                            i.kendoDropDownList({ filter: "contains", placeholder: "请选择咨询项目", dataSource: r, dataTextField: "itemName", dataValueField: "itemName", select: function(t) { n.searchCriteria.consultItem = this.dataItem(t.item)[this.options.dataValueField] || null;
                                    Ares.sensors.trackDropDownEvent("ConsultList", "咨询项目") } }) }) }) },
                a = function(n) { f.goToPatient(n) };
            (function() { n.isAlloweViewAllConsults = c.isAllowed("consultCenter.viewAllConsults");
                n.isAllowExportConsults = c.isAllowed("consultCenter.exportConsults");
                n.initView = o;
                n.initConsultStateDropdown = r;
                n.initVisitStateDropdown = u;
                n.initConsultantDropdown = e;
                n.goToPatient = a;
                n.initSearchCriteriaData();
                r();
                s();
                u();
                e();
                l();
                n.searchConsultPagedList() })() } } }]);
managementModule.directive("consultNetworkListView", ["$log", "$timeout", "$q", "$window", "apptUtil", "appNav", "officeOptionSvc", "aresNotification", "loginContext", "localCache", "sessionCache", "gridOptionUtil", "dataDicSvc", "aresDialog", "dashboardSvc", "practiceSvc", "patientUtil", "enums", "eventAggregator", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y, p, w, b) { "use strict"; return { restrict: "E", replace: !0, templateUrl: "/app/management/views/consult/consult-network-list-view.html", controller: "ConsultNetworkListCtrl", link: function(n, i) { var d = Ares.kendoGridUtil(r, n),
                p = null,
                gt = c.getCache(c.keys.PageSize),
                k = h.getCache(h.keys.GroupDashboardOnlineConsultFields),
                f = k.loadObject();
            f = _.isArray(f) ? f : []; var v = null,
                g = [{ field: "rowNumber", title: " ", sortable: !1, index: 0, code: "index", width: "32px", template: "<span class='row-number'><\/span>", attributes: { style: "padding: 0" } }, { field: "patientName", title: "姓名", width: "120px", isHidden: !1, code: "patientName", index: 30 }, { field: "sexStr", title: "性别", width: "80px", isHidden: !0, code: "sexStr", index: 40 }, { field: "ageStr", title: "年龄", width: "80px", isHidden: !0, code: "ageStr", index: 50 }, { field: "mobile", title: "手机", width: "120px", isHidden: !1, code: "mobile", index: 60 }, { field: "privateId", title: "病历号", width: "150px", isHidden: !1, code: "privateId", index: 70 }, { field: "sourceType1", title: "来源一级", width: "120px", isHidden: !0, code: "sourceType1", index: 80 }, { field: "sourceType2", title: "来源二级", width: "120px", isHidden: !0, code: "sourceType2", index: 90 }, { field: "sourceType3", title: "来源三级", width: "120px", isHidden: !0, code: "sourceType3", index: 100 }, { field: "createdUser", title: "创建人", width: "120px", isHidden: !1, code: "createdUser", index: 110 }, { field: "consultTimeStr", title: "咨询时间", width: "180px", isHidden: !1, code: "consultTimeStr", index: 120 }, { field: "consultItems", title: "咨询项目", width: "120px", isHidden: !1, code: "consultItems", index: 130 }, { field: "content", title: "咨询内容", width: "120px", isHidden: !1, code: "content", index: 140 }, { field: "intention", title: "成交意愿", width: "120px", isHidden: !1, code: "intention", index: 145 }, { field: "patientStatus", title: "患者状态", width: "180px", sortable: !1, isHidden: !0, code: "patientStatus", index: 146, template: function(n) { return n.hasAppt ? n.firstVisit ? "已到店" : "已约未到店" : "未约" } }, { field: "nextApptTimeStr", title: "下次预约时间", sortable: !1, width: "180px", isHidden: !0, code: "nextApptTimeStr", index: 147 }, { field: "nextCheckInTimeStr", title: "下次挂号时间", sortable: !1, width: "180px", isHidden: !0, code: "nextCheckInTimeStr", index: 148 }, { field: "nextApptStatus", title: "下次预约状态", sortable: !1, width: "180px", isHidden: !0, code: "nextApptStatus", index: 149 }, { field: "nextApptItems", title: "下次预约项目", sortable: !1, width: "180px", isHidden: !0, code: "nextApptItems", index: 150 }, { field: "method", title: "沟通方式", width: "120px", isHidden: !0, code: "method", index: 155 }, { field: "notes", title: "备注", width: "120px", isHidden: !1, code: "notes", index: 160 }, ],
                e = null,
                nt = function() { var r = this,
                        u = r.element,
                        t = u.find(".k-grid-header"),
                        f = t.find(".k-header-column-menu:gt(0)").length;
                    f > 0 && (t.find(".k-header-column-menu:gt(0)").remove(), t.find(".k-header:gt(0)").each(function(n, t) { var i = $(t).find("a");
                        i.css("margin-right", "0") }));
                    $(i).find("#groupOnlineConsultList table tbody tr").each(function(t, u) { var f = r.dataItem(u),
                            e = i.find("#groupOnlineConsultList").data("kendoGrid"),
                            t = $(this).index() + 1 + n.pageSize * (n.pageIndex - 1);
                        $("td .row-number", u).html(t) }) },
                tt = function(t) { n.showColumns = t;
                    u() },
                o = function(n, i) { v && t.cancel(v);
                    v = t(function() { if (i) { var t = _.find(f, { code: n.column.code });
                            t && (t.width = n.newWidth + "px", k.saveObject(f)) } else l.updateColumnsOption(l.keys.groupDashboardOnlineConsultGridOption, n.sender.columns, tt) }, 500) },
                it = function(t) { var i = n.showColumns; return i = _.filter(i, function(n) { return n && n.indexOf("undefined") == -1 }), l.formatColumns(t, i, f), t = _.sortBy(t, "index"), angular.forEach(t, function(n) { f.push({ code: n.code, width: n.width }) }), t },
                u = function() { n.refreshOnlineConsult().then(function(t) { t.items || (t.items = []);
                        n.updateCount();
                        e = angular.copy(g);
                        e = it(e); var u = i.find("#groupOnlineConsultList"),
                            s = u.offset().top,
                            f = r.innerHeight - 220 - (window.Ares3 ? 60 : 0);
                        e.push({ template: d.commandTemplate, title: "", width: "160px", index: 200 });
                        p = u.kendoGrid({ excel: { allPages: !0 }, dataSource: { data: t.items }, height: f, model: { id: "id" }, columns: e, dataBound: nt, sortable: !0, resizable: !0, reorderable: !0, columnMenu: !0, columnShow: function(n) { o(n) }, columnHide: function(n) { o(n) }, columnMenuInit: function(n) { n.container.find(".k-sort-asc").remove();
                                n.container.find(".k-sort-desc").remove(); var t = $(n.container).find(".k-menu-group");
                                t.find("li").each(function(n, t) { var i = $(t).text();
                                    i == " " && $(t).remove() }) }, columnReorder: function(n) { o(n) }, columnResize: function(n) { o(n, !0) } }).data("kendoGrid") }) },
                rt = function() { u() },
                ut = [{ text: "修改咨询记录", action: "update", icon: "glyphicon-pencil", className: "edit-command" }, { text: "删除咨询记录", action: "delete", icon: "glyphicon glyphicon-trash", className: "cell-command" }, ],
                ft = function(t) { return _.find(n.pageData.items, function(n) { return n.id == t }) },
                et = function(t, i, r) { var u = ft(r);
                    n.$apply(function() { switch (i) {
                            case "update":
                                n.editConsult(u); break;
                            case "delete":
                                n.deleteOnlineConsult(u.onlineConsultId) } });
                    Ares.sensors.trackGridEvent(t, "ConsultNetworkList") },
                ot = function() { n.initSearchCriteria().then(function(n) { var t = { criteria: n, columns: p.columns };
                        y.exportGroupOnlineConsult(t) }) },
                st = function() { a.groupConsultantDic.loadActive().then(function(t) { var r = w.getPatientPermissionLevel(),
                            f;
                        r == b.PatientPermissionLevel.Department ? t = _.filter(t, function(n) { return n.department == s.department }) : r == b.PatientPermissionLevel.Personal && (t = _.filter(t, function(n) { return n.id == s.providerId }));
                        f = i.find("#groupOnlineConsultantInput").kendoDropDownList({ dataSource: t, optionLabel: "全部", dataTextField: "name", dataValueField: "userID", select: function(t) { n.userId = this.dataItem(t.item)[this.options.dataValueField] || -1;
                                u();
                                Ares.sensors.trackDropDownEvent("ConsultNetworkList", "创建人") } }) }) },
                ht = function() { a.consultItemDic.load().then(function(t) { n.consultItems = t;
                        i.find("#consultItems").kendoDropDownList({ optionLabel: "全部", dataTextField: "itemName", dataValueField: "itemName", autoBind: !1, filter: "contains", dataSource: t, select: function(t) { n.consultItem = this.dataItem(t.item)[this.options.dataValueField] || null;
                                u() } }) }) },
                ct = function() { var n = $(window).height(),
                        t = n - 240,
                        i = t - 81; return Math.max(5, parseInt(i / 40)) },
                lt = function(t) { n.pageIndex = t;
                    u() },
                at = function(t) { n.pageSize = t;
                    u() },
                vt = function() { n.loadColumnsOption().then(function() { u() }) },
                yt = function(t) { n.timeSpan || n.initDefaultTimeSpan(); switch (t) {
                        case "all":
                            n.timeSpan.startDate = null;
                            n.timeSpan.endDate = null;
                            n.selectDate = "all"; break;
                        case "day":
                            n.timeSpan.startDate = moment(Ares.today()).toDate();
                            n.timeSpan.endDate = moment(Ares.today()).add(1, "day").toDate();
                            n.selectDate = "day"; break;
                        case "week":
                            n.timeSpan.startDate = moment(Ares.today()).startOf("week").toDate();
                            n.timeSpan.endDate = moment(Ares.today()).endOf("week").toDate();
                            n.selectDate = "week"; break;
                        case "month":
                            n.timeSpan.startDate = moment(Ares.today()).startOf("month").toDate();
                            n.timeSpan.endDate = moment(Ares.today()).endOf("month").toDate();
                            n.selectDate = "month"; break;
                        case "custom":
                            n.timeSpan.endDate || n.initDefaultTimeSpan();
                            n.selectDate = "custom" } u() },
                pt = function(t) { t == "previous" ? (n.timeSpan.startDate = moment(n.timeSpan.startDate).add(-1, n.selectDate).startOf(n.selectDate).toDate(), n.timeSpan.endDate = moment(n.timeSpan.endDate).add(-1, n.selectDate).endOf(n.selectDate).toDate()) : t == "next" && (n.timeSpan.startDate = moment(n.timeSpan.startDate).add(1, n.selectDate).startOf(n.selectDate).toDate(), n.timeSpan.endDate = moment(n.timeSpan.endDate).add(1, n.selectDate).endOf(n.selectDate).toDate());
                    u() },
                wt = function() { a.systemItemDic.loadActive({ itemType: "成交意愿" }).then(function(n) { var t = i.find("#intention-input").data("kendoMultiSelect");
                        t ? t.dataSource.data(n) : i.find("#intention-input").kendoMultiSelect({ maxSelectedItems: 9, placeholder: "全部", dataTextField: "itemName", dataValueField: "itemName", dataSource: n, change: function() { u();
                                Ares.sensors.trackDropDownEvent("ConsultNetworkList", "成交意愿") } }) }) },
                bt = function() { var n = null,
                        t = i.find("#intention-input").data("kendoMultiSelect"); return t && (n = t.value().join(",")), n },
                kt = function() { u() },
                dt = function() { u() };
            (function() { n.isAres3 = window.Ares3;
                n.isGroup = s.isGroup;
                n.officeId = n.isGroup ? 0 : s.officeId;
                n.selectCode = "";
                n.selectDate = "all";
                n.pageIndex = 1;
                n.content = "";
                n.apptStatus = { none: !1, noCheckin: !1, checkin: !1 };
                n.pageSize = ct();
                n.updateDate = pt;
                n.switchDate = yt;
                n.onPageChanged = lt;
                n.onContentChanged = kt;
                n.providerJob = s.providerJob;
                n.onPageSizeChanged = at;
                n.toggleStateSelection = rt;
                n.isDepartmentLevel = w.getPatientPermissionLevel() == b.PatientPermissionLevel.All || w.getPatientPermissionLevel() == b.PatientPermissionLevel.Department;
                n.commands = ut;
                n.onCommandClick = et;
                n.exportExcel = ot;
                n.refreshGrid = u;
                n.getIntentions = bt;
                n.onApptStatusClick = dt;
                vt();
                wt();
                t(function() { st();
                    ht() }) })() } } }]);
managementModule.directive("sceneConsultListView", ["$log", "$timeout", "$modal", "$filter", "$window", "$state", "appNav", "enums", "permissionProvider", "dataDicSvc", "patientSvc", "commonTaskSvc", function(n, t, i, r, u, f, e, o, s, h, c, l) { "use strict"; return { restrict: "E", replace: !0, scope: { officeId: "=" }, templateUrl: "/app/management/views/consult/scene-consult-list-view.html", controller: "sceneConsultListCtrl", link: function(n, r) { var o = Ares.kendoGridUtil(u, n),
                c = !1;
            $("#daysBeforeTodayInput").val() == "自定义" ? $(".isHideData").show() : $(".isHideData").hide();
            $("#daysBeforeTodayInput").change(function() { $("#daysBeforeTodayInput").val() == "自定义" ? $(".isHideData").show() : $(".isHideData").hide() }); var a = function() { var t, i;
                    n.searchResult && n.searchResult.items && (c = !0, t = $(r).find("#sceneConsultList"), t.kendoGrid({ dataSource: { data: n.searchResult.items }, scrollable: !1, sortable: !0, selectable: "single", dataBound: y, model: { id: "id" }, columns: [{ field: "name", title: "姓名", width: "40px" }, { field: "privateId", title: "病历号", width: "40px" }, { field: "consultantName", title: "咨询师", width: "40px" }, { field: "startTime", title: "预约时间", width: "60px" }, { field: "consultItem", title: "咨询项目", width: "80px" }, { field: "taskStatusStr", title: "咨询状态", width: "60px" }, { field: "checkInType", title: "就诊类型", width: "60px" }, { field: "notes", title: "备注", width: "100px", attributes: { "class": "wrap-prompt" } }, { template: o.commandTemplate, title: "操作", width: "110px", field: "option" }] }), i = t.data("kendoGrid")) },
                v = [{ text: "忽略", action: "goToCancelTask", icon: "glyphicon-remove" }, { text: "就诊记录", action: "goToApptRecord", icon: "glyphicon-eye-open" }, { text: "咨询记录", action: "goToConsultRecord", icon: "glyphicon-list" }, { text: "创建咨询", action: "goToAddConsult", icon: "glyphicon-plus-sign" }, ],
                y = function() { var t = this;
                    $(r).find("#sceneConsultList table tbody tr").each(function(i, r) { var u = t.dataItem(r),
                            e = $(".btn-group", r),
                            f;
                        u.taskStatus == 1 ? $('.btn-group button[data-action="goToCancelTask"]', r).attr("disabled", "true") : u.taskStatus == 2 && ($('.btn-group button[data-action="goToCancelTask"]', r).attr("disabled", "true"), $('.btn-group button[data-action="goToAddConsult"]', r).attr("disabled", "true"));
                        f = Ares.today();
                        n.isStrongStrict && new Date(u.startTimeSource) < f && $('.btn-group button[data-action="goToAddConsult"]', r).attr("disabled", "true") }) },
                p = function() { var n = f.params.patientId;
                    n && t(function() { ut(n) }, 500) },
                w = function(t, i, r) { var u = _.find(n.searchResult.items, function(n) { return n.id == r });
                    n.$apply(function() { switch (i) {
                            case "goToConsultRecord":
                                k(u.patientId); break;
                            case "goToApptRecord":
                                d(u.patientId); break;
                            case "goToCancelTask":
                                b(u.id); break;
                            case "goToAddConsult":
                                g(u.patientId) } });
                    Ares.sensors.trackGridEvent(t, "SceneConsultList", i, ["goToCancelTask", "goToAddConsult", "goToCancelTask"]) },
                b = function(t) { ft(t).then(function() { n.search() }) },
                k = function(n) { e.goToConsultRecord(n) },
                d = function(n) { e.goToApptRecord(n) },
                g = function(n) { e.goToAddConsult(n, { patientId: n }) },
                nt = function() { h.consultantDic.loadActive().then(function(t) { var e = t,
                            o = { id: -1, name: "全部" },
                            i, u, f;
                        e.splice(0, 0, o);
                        i = r.find("#consultantInput");
                        i.kendoDropDownList({ dataSource: e, placeholder: "", dataTextField: "name", dataValueField: "id", value: n.consultantId.id, select: function(t) { var i = this.dataItem(t.item.index());
                                n.consultantId = i.id;
                                Ares.sensors.trackDropDownEvent("SceneConsultList", "咨询师") } });
                        u = i.data("kendoDropDownList");
                        f = n.sceneConsultListCache.loadObject();
                        f.consultanttask_consultantId ? (n.consultantId = f.consultanttask_consultantId, u.value(n.consultantId)) : u.value(o.id) }) },
                tt = function() { h.consultItemDic.loadActive().then(function(i) { i.unshift({ itemName: "全部" });
                        t(function() { var t = r.find("#consultItemInput");
                            t.kendoDropDownList({ filter: "contains", placeholder: "请选择咨询项目", dataSource: i, dataTextField: "itemName", dataValueField: "itemName", select: function(t) { n.consultItem = this.dataItem(t.item)[this.options.dataValueField] || null;
                                    Ares.sensors.trackDropDownEvent("SceneConsultList", "咨询项目") } }) }) }) },
                it = function() { h.systemsettingDic.loadActive().then(function(t) { var i = _.filter(t, function(n) { return n.itemType == "就诊类型" }),
                            u;
                        i.unshift({ itemName: "全部" });
                        u = r.find("#visitStateInput");
                        u.kendoDropDownList({ dataSource: i, dataTextField: "itemName", dataValueField: "itemName", value: n.checkInType, select: function(t) { var i = this.dataItem(t.item.index());
                                n.checkInType = i.itemName === "全部" ? null : i.itemName;
                                Ares.sensors.trackDropDownEvent("SceneConsultList", "初复诊") } }) }) },
                rt = function() { var t = $("#sceneConsultList"),
                        i = t.data("kendoGrid");
                    i.dataSource.data(n.searchResult.items) },
                ut = function(n) { var t = $(r).find("#patientList"),
                        i = t.data("kendoGrid"),
                        f = i.dataSource,
                        e = f.get(n),
                        u = t.find("tbody>tr[data-uid=" + e.uid + "]");
                    u && i.select(u) },
                ft = function(n) { var t = i.open({ animation: !0, backdrop: "static", controller: "sceneConsultListDialogCtrl", template: "<scene-consult-list-dialog-view><\/scene-consult-list-dialog-view>", size: "lg", windowClass: "small-dialog", resolve: { host: function() { return { taskId: n } } } }); return t.result },
                et = function() { var t = r.find("#statusInput"),
                        i;
                    t.kendoDropDownList({ dataSource: [{ id: -1, name: "全部" }, { id: 0, name: "未写" }, { id: 1, name: "已写" }, { id: 2, name: "已忽略" }], dataTextField: "name", dataValueField: "id", height: 230, select: function(t) { n.status = this.dataItem(t.item)[this.options.dataValueField];
                            Ares.sensors.trackDropDownEvent("SceneConsultList", "状态") } });
                    i = t.data("kendoDropDownList");
                    i.value(n.status) },
                ot = function() { var n = $(window).height(),
                        t = n - 240,
                        i = t - 81; return Math.max(5, parseInt(i / 40)) },
                st = function(t) { n.pageIndex = t;
                    n.search() },
                ht = function(t) { n.pageSize = t;
                    n.search() },
                ct = function() { var t = n.initCriteria(),
                        i = $(r).find("#sceneConsultList"),
                        u = i.data("kendoGrid"),
                        f = { criteria: t, columns: u.columns };
                    l.exportConsultantRecordTasks(f) };
            (function() { n.selectCode = "";
                n.height = u.innerHeight - 260 - (window.Ares3 ? 20 : 0) + "px";
                n.commands = v;
                n.onCommandClick = w;
                n.pageIndex = 1;
                n.pageSize = ot();
                n.onPageChanged = st;
                n.onPageSizeChanged = ht;
                n.exportExcel = ct;
                n.isAllowExportConsults = s.isAllowed("consultCenter.exportConsults");
                et();
                nt();
                tt();
                it();
                n.$watch("searchResult", function() { n.searchResult && (c ? rt() : (a(), p())) });
                n.$on("$destroy", function() { o.dispose() }) })() } } }]);
managementModule.directive("customerClueHomeView", ["$log", "appNav", "$modal", function(n, t) { "use strict"; return { restrict: "E", templateUrl: "/app/management/views/customer-clue/customer-clue-home-view.html", link: function(n) { var i = function() { var i = [new t.TabItem("customerClue.management", "线索管理", "", Ares.isDebugEnabled ? null : "customerClueManagement.management")];
                n.states = i };
            (function() { i() })() } } }]);
managementModule.directive("customerClueManagementView", ["$log", "$window", "$modal", "$timeout", "$q", "kendoUtil", "gridOptionUtil", "aresDialog", "appNav", "aresModalShelf", "aresNotification", function(n, t, i, r, u, f, e, o, s, h, c) { "use strict"; return { templateUrl: "/app/management/views/customer-clue/customer-clue-management-view.html", controller: "CustomerClueManagementCtrl", link: function(n, u) { var p, w, b, k, d, g, ut = [{ name: "全部线索状态", value: null }, { name: "未开始", value: 1 }, { name: "进行中", value: 2 }, { name: "已完成", value: 3 }],
                ft = function() { w = u.find("#assigneeProvider").kendoMultiSelect({ dataSource: n.AssigeeProviders, dataTextField: "name", dataValueField: "id", placeholder: "全部跟进员工", change: function() { n.criteria.assigneeProviderIds = this.value() ? this.value().join() : null } }).data("kendoMultiSelect") },
                et, ot = function() { et = u.find("#assignerProvider").kendoDropDownList({ dataSource: n.providers, filter: "contains", dataTextField: "name", dataValueField: "id", optionLabel: "全部分配人", select: function(t) { n.criteria.assignerProviderId = this.dataItem(t.item)[this.options.dataValueField] || null } }).data("kendoDropDownList") },
                st, ht = function() { st = u.find("#recordCreatedUser").kendoDropDownList({ dataSource: n.providers, filter: "contains", dataTextField: "name", dataValueField: "id", optionLabel: "全部导入人", select: function(t) { var i = this.dataItem(t.item);
                            n.criteria.recordCreatedUser = i.userID } }).data("kendoDropDownList") },
                ct = function() { p = u.find("#isAssigned").kendoDropDownList({ dataSource: [{ name: "全部分配状态", value: null }, { name: "未分配", value: 0 }, { name: "已分配", value: 1 }], dataTextField: "name", dataValueField: "value", select: function(t) { var i = this;
                            r(function() { n.criteria.isAssigned = i.dataItem(t.item)[i.options.dataValueField] }) } }).data("kendoDropDownList") },
                lt = function() { b = u.find("#isVisited").kendoDropDownList({ dataSource: [{ name: "全部到店状态", value: null }, { name: "到店", value: 1 }, { name: "未到店", value: 0 }], dataTextField: "name", dataValueField: "value", select: function(t) { var i = this;
                            r(function() { n.criteria.isVisited = i.dataItem(t.item)[i.options.dataValueField] }) } }).data("kendoDropDownList") },
                v = function(t, i) { var f = u.find("#" + t),
                        r = f.kendoDropDownList({ dataSource: n.systemSettingitems, dataTextField: "itemName", dataValueField: "itemName" }).data("kendoDropDownList");
                    i == "first" ? k = r : i == "next" ? d = r : i == "last" && (g = r) },
                nt = [{ field: "isAssigned", title: "分配状态", width: "85px", locked: !0, template: function(n) { return n.isAssigned ? "已分配" : "未分配" } }, { field: "state", title: "线索状态", width: "85px", template: function(n) { var t = n.state,
                            i = _.find(ut, function(n) { return n.value == t }) || ""; return '<span class="customerClue-status-' + t + '">' + i.name + "<\/span>" } }, { field: "sourceTypeLevel1", title: "一级来源", width: "85px" }, { field: "sourceType", title: "二级来源", width: "85px" }, { field: "refereeName", title: "三级来源", width: "85px" }, { field: "patientName", title: "患者姓名", width: "85px" }, { field: "customerName", title: "诉求姓名", width: "85px" }, { field: "mobile", title: "手机号码", width: "120px" }, { field: "complaintContent", title: "咨询内容", width: "120px" }, { field: "complaintItem", title: "咨询项目", width: "120px" }, { field: "complaintTime", title: "咨询日期", width: "110px", template: function(n) { return f.dateFormat(n.complaintTime) } }, { field: "recordCreatedName", title: "导入人", width: "120px" }, { field: "recordCreatedTime", title: "导入日期", width: "110px", template: function(n) { return f.dateFormat(n.recordCreatedTime) } }, { field: "assignerProviderName", title: "分配人", width: "120px" }, { field: "assignTime", title: "分配日期", width: "110px", template: function(n) { return f.dateFormat(n.assignTime) } }, { field: "assigneeProviderName", title: "线索跟进人", width: "120px" }, { field: "firstFollow", title: "首次回访", width: "85px" }, { field: "nextFollow", title: "再次回访", width: "85px" }, { field: "lastFollow", title: "末次回访", width: "85px" }, { field: "startTime", title: "预约日期", width: "110px", template: function(n) { return f.dateFormat(n.startTime) } }, { field: "proceduresName", title: "预约项目", width: "85px" }, { field: "isVisited", title: "是否到店", width: "85px", template: function(n) { return n.isVisited ? "已到店" : "未到店" } }, { field: "", title: "操作", width: "130px", locked: !0, template: function(n) { var t = n.id,
                            i = n.state,
                            r = '<span class="enyo-text-primary edit-button" dataId="' + t + '" state="' + i + '" type="detail"  style="margin-right:10px;">查看<\/span>'; return r + ('<span class="enyo-text-primary edit-button" dataId="' + t + '" state="' + i + '" type="editDetail" style="margin-right:10px;" ares-authorize="customerClueManagement.edit">编辑<\/span>') } }, ],
                tt = f.CommonColumnsNotINHeader.checkboxColumn;
            tt.locked = !1;
            nt.splice(0, 0, tt); var it = null,
                a, l = function(i) { n.refreshListData(i).then(function(n) { var i, r;
                        it = angular.copy(nt);
                        i = u.find("#customerClueManagementGrid");
                        i.html("");
                        r = t.innerHeight - 295;
                        a = i.kendoGrid({ excel: { allPages: !0 }, dataSource: { data: n.items }, height: r, model: { id: "id" }, columns: it, sortable: !1, resizable: !0, reorderable: !0, columnMenu: !0, dataBound: at, columnMenuInit: function(n) { $(n.container).find("ul.k-menu >li:not(.k-columns-item)").remove();
                                $(n.container).find("ul.k-menu >li.k-columns-item >div> ul> li.k-first").hide() }, columnShow: function(n) { var t = n.sender.columns;
                                e.updateColumnsOption(e.keys.customerClueManagementGridOption, t, rt) }, columnHide: function(n) { var t = n.sender.columns;
                                e.updateColumnsOption(e.keys.customerClueManagementGridOption, t, rt) } }).data("kendoGrid") }) },
                at = function() { $(u).find("#customerClueManagementGrid table tbody tr td .commonColumns_sub_checkbox").each(function() { $(this).bind("click", function(t) { var i = f.selectSingleRow(a, "customerClueManagementGrid", n.pageData.items.length, this, t);
                            vt(i) }) });
                    $(u).find("#customerClueManagementGrid tbody tr td .edit-button").each(function() { $(this).bind("click", function() { var n = $(this).attr("dataId"),
                                t = $(this).attr("type");
                            oi(n, t) }) }) },
                vt = function(t) { n.selectedRows = t;
                    r(function() { n.selectTotalCount = n.selectedRows == n.pageData.totalCount }) },
                rt = function(t) { n.showColumns = t },
                yt = function() { var i = f.getCustomSelectedData(a),
                        t = []; return n.isAssignedFlag = !1, i.forEach(function(i) { i.isAssigned && (n.isAssignedFlag = !0);
                        t.push(i.id) }), t = _.uniq(t) },
                pt = function(t) { var i = u.find("#customerClueManagementGrid"),
                        r = f.selectAllRow(a, "customerClueManagementGrid", t);
                    n.selectedRows = t ? n.pageData.items.length : 0 },
                wt = function(t) { n.criteria.pageIndex = t;
                    l() },
                bt = function(t) { n.criteria.pageSize = t;
                    l() },
                kt = function() { ct();
                    lt();
                    dt();
                    ni();
                    ii();
                    ui();
                    n.initProviders().then(function() { ot();
                        ht() });
                    n.initAssigeeProviders().then(function() { ft() });
                    n.initItemType().then(function() { v("firstFollow", "first");
                        v("nextFollow", "next");
                        v("lastFollow", "last") });
                    l(!1) },
                dt = function() { var t = moment(new Date).startOf("week").toDate(),
                        i = moment(new Date).endOf("week").toDate();
                    n.criteria.startRecordCreateTime = t;
                    n.criteria.endRecordCreateTime = moment(i).add(1, "day").format("YYYY-MM-DD");
                    n.timeSpanCreatedTime = { startDate: t, endDate: i } },
                gt = function(t) { t = t || n.timeSpanCreatedTime;
                    n.criteria.startRecordCreateTime = moment(t.startDate).format("YYYY-MM-DD");
                    n.criteria.endRecordCreateTime = moment(t.endDate).add(1, "day").format("YYYY-MM-DD") },
                ni = function() { var t = moment().format("YYYY-MM-DD"),
                        i = t;
                    n.timeSpanComplaintTime = { startDate: null, endDate: null } },
                ti = function(t) { t = t || n.timeSpanComplaintTime;
                    n.criteria.startComplaintTime = moment(t.startDate).format("YYYY-MM-DD");
                    n.criteria.endComplaintTime = moment(t.endDate).add(1, "day").format("YYYY-MM-DD") },
                ii = function() { var t = moment().format("YYYY-MM-DD"),
                        i = t;
                    n.timeSpanAppointmentTime = { startDate: null, endDate: null } },
                ri = function(t) { t = t || n.timeSpanAppointmentTime;
                    n.criteria.appointmentStartTime = moment(t.startDate).format("YYYY-MM-DD");
                    n.criteria.appointmentEndTime = moment(t.endDate).add(1, "day").format("YYYY-MM-DD") },
                ui = function() { var t = moment().format("YYYY-MM-DD"),
                        i = t;
                    n.timeSpanAssignTime = { startDate: null, endDate: null } },
                fi = function(t) { t = t || n.timeSpanAssignTime;
                    n.criteria.startAssignTime = moment(t.startDate).format("YYYY-MM-DD");
                    n.criteria.endAssignTime = moment(t.endDate).add(1, "day").format("YYYY-MM-DD") },
                ei = function() { p.value(null);
                    w.value(null);
                    b.value(null);
                    k.value("全部");
                    d.value("全部");
                    g.value("全部");
                    n.initCriteria();
                    l(1) },
                y = function() { l(1) },
                oi = function(t, i) { var r = h.open({ template: "<customer-clue-track-edit-view><\/customer-clue-track-edit-view>", controller: "CustomerClueTrackEditCtrl", title: "线索信息", titleIconClass: "iconfont icon-xiansuo1-copy", resolve: { host: function() { return { customerClueId: t, type: i, systemSettingitems: n.systemSettingitems } } }, needActive: !0 });
                    r.result.then(function(n) { n && y() }) },
                si = function() { var t = yt(),
                        r; if (!t.length) { o.warn("提示", "请选择需要分配的线索！"); return } if (n.isAssignedFlag) { o.warn("提示", "已分配线索不可再分配！"); return } r = i.open({ animation: !0, backdrop: "static", template: "<customer-clue-allocation-view><\/customer-clue-allocation-view>", controller: "CustomerClueAllocationCtrl", backdropClass: "ares-modal-backdrop", resolve: { host: function() { return { customerClueIds: t } } } });
                    r.result.then(function(n) { n && y() }) },
                hi = function() { n.searchMode = !n.searchMode },
                ci = function() { s.goToState("importCenter.clue") },
                li = function() { n.closeCustomerClue().then(function() { l(1);
                        c.success("成功关闭所有到店线索！") }) };
            (function() { n.onPageChanged = wt;
                n.onPageSizeChanged = bt;
                n.refresh = ei;
                n.search = y;
                n.switchMode = hi;
                n.allocationClue = si;
                n.onAllCheckboxClicked = pt;
                n.exportExcel = ci;
                n.itemType = "线索追踪";
                n.onCreatedTimeChanged = gt;
                n.onComplaintTimeChanged = ti;
                n.onAppointmentTimeChanged = ri;
                n.onAssignTimeChanged = fi;
                n.closeCustormer = li;
                kt() })() } } }]);
managementModule.directive("customerClueTrackView", ["$log", "$window", "$modal", "aresModalShelf", "$timeout", "$q", "kendoUtil", "gridOptionUtil", "aresDialog", "appNav", "loginContext", function(n, t, i, r, u, f, e, o, s, h, c) { "use strict"; return { templateUrl: "/app/management/views/customer-clue/customer-clue-track-view.html", controller: "CustomerClueTrackCtrl", link: function(n, f) { var l, a, v, y, p = [{ name: "全部线索状态", value: null }, { name: "未开始", value: 1 }, { name: "进行中", value: 2 }, { name: "已完成", value: 3 }],
                g = function() { l = f.find("#customerClueState").kendoDropDownList({ dataSource: p, dataTextField: "name", dataValueField: "value", select: function(t) { var i = this;
                            u(function() { n.criteria.state = i.dataItem(t.item)[i.options.dataValueField] }) } }).data("kendoDropDownList") },
                h = function(t, i) { var u = f.find("#" + t),
                        r = u.kendoDropDownList({ dataSource: n.systemSettingitems, dataTextField: "itemName", dataValueField: "itemName" }).data("kendoDropDownList");
                    i == "first" ? a = r : i == "next" ? v = r : i == "last" && (y = r) },
                nt = [{ field: "state", title: "线索状态", width: "85px", locked: !0, template: function(n) { var t = n.state,
                            i = _.find(p, function(n) { return n.value == t }) || ""; return '<span class="customerClue-status-' + t + '">' + i.name + "<\/span>" } }, { field: "channelLevel1", title: "一级渠道", width: "85px" }, { field: "channelLevel2", title: "二级渠道", width: "85px" }, { field: "patientName", title: "患者姓名", width: "85px" }, { field: "customerName", title: "诉求姓名", width: "85px" }, { field: "mobile", title: "手机号码", width: "120px" }, { field: "complaintContent", title: "客户诉求", width: "120px" }, { field: "complaintItem", title: "客户项目", width: "120px" }, { field: "recordCreatedTime", title: "提交日期", width: "110px", template: function(n) { return e.dateFormat(n.recordCreatedTime) } }, { field: "firstFollow", title: "首次回访", width: "85px" }, { field: "nextFollow", title: "再次回访", width: "85px" }, { field: "lastFollow", title: "末次回访", width: "85px" }, { field: "complaintTime", title: "诉求日期", width: "110px", template: function(n) { return e.dateFormat(n.complaintTime) } }, { field: "startTime", title: "预约日期", width: "110px", template: function(n) { return e.dateFormat(n.startTime) } }, { field: "proceduresName", title: "预约项目", width: "85px" }, { field: "isVisited", title: "是否到店", width: "85px", template: function(n) { return n.isVisited ? "已到店" : "未到店" } }, { field: "", title: "操作", width: "130px", locked: !0, template: function(n) { var i = n.id,
                            t = n.state,
                            u = t == 2 ? "编辑" : "查看",
                            r = '<span class="enyo-text-primary edit-button" dataId="' + i + '" state="' + t + '" type="edit" style="margin-right:10px;">' + u + "<\/span>"; return r += '<span class="enyo-text-primary edit-button" dataId="' + i + '" state="' + t + '" patientId="' + n.patientId + '" type="improve" style="margin-right:10px;">完善<\/span>', r + ('<span class="enyo-text-primary edit-button" dataId="' + i + '" state="' + t + '" patientId="' + n.patientId + '" type="appoint">预约<\/span>') } }, ],
                w = null,
                b, s = function(i) { n.refreshListData(i).then(function(n) { var i, r;
                        w = angular.copy(nt);
                        i = f.find("#customerClueTrackGrid");
                        i.html("");
                        r = t.innerHeight - 210;
                        b = i.kendoGrid({ excel: { allPages: !0 }, dataSource: { data: n.items }, height: r, model: { id: "id" }, columns: w, sortable: !1, resizable: !0, reorderable: !0, columnMenu: !0, dataBound: tt, columnMenuInit: function(n) { $(n.container).find("ul.k-menu >li:not(.k-columns-item)").remove();
                                $(n.container).find("ul.k-menu >li.k-columns-item >div> ul> li.k-first").hide() }, columnShow: function(n) { var t = n.sender.columns;
                                o.updateColumnsOption(o.keys.customerClueTrackGridOption, t, k) }, columnHide: function(n) { var t = n.sender.columns;
                                o.updateColumnsOption(o.keys.customerClueTrackGridOption, t, k) } }).data("kendoGrid") }) },
                tt = function() { $(f).find("#customerClueTrackGrid tbody tr td .edit-button").each(function() { $(this).bind("click", function() { var n = $(this).attr("dataId"),
                                u = $(this).attr("state"),
                                t = $(this).attr("type"),
                                i = $(this).attr("patientId"),
                                r;
                            t == "edit" ? (r = u == 2 ? "edit" : "detail", et(n, r)) : t == "improve" ? st(n, i) : t == "appoint" && ht(n, i) }) }) },
                k = function(t) { n.showColumns = t },
                lt = function() { var t = e.getCustomSelectedData(b),
                        n = []; return t.forEach(function(t) { n.push(t.id) }), n = _.uniq(n) },
                it = function(t) { n.criteria.pageIndex = t;
                    s() },
                rt = function(t) { n.criteria.pageSize = t;
                    s() },
                ut = function() { g();
                    n.initItemType().then(function() { h("firstFollow", "first");
                        h("nextFollow", "next");
                        h("lastFollow", "last") });
                    s(!1) },
                ft = function() { l.value(null);
                    a.value("全部");
                    v.value("全部");
                    y.value("全部");
                    n.initCriteria();
                    s(1) },
                d = function() { s(1) },
                et = function(t, i) { var u = r.open({ template: "<customer-clue-track-edit-view><\/customer-clue-track-edit-view>", controller: "CustomerClueTrackEditCtrl", title: "线索信息", titleIconClass: "iconfont icon-xiansuo1-copy", resolve: { host: function() { return { customerClueId: t, type: i, systemSettingitems: n.systemSettingitems } } }, needActive: !0 });
                    u.result.then(function(n) { n && d() }) },
                ot = function() { var t = i.open({ animation: !0, backdrop: "static", template: "<patient-quick-edit-view><\/patient-quick-edit-view>", controller: "PatientQuickEditCtrl", windowClass: "patient-quick-edit-dialog", size: "lg", resolve: { patientHost: function() { return { patient: n.patient } } } }) },
                st = function(t, i) { n.getPatient(i).then(function() { ot() }) },
                ht = function(t, i) { c.isAdminOffice ? n.createCrossOfficeAppt(t, i) : n.createFollowUpApptByPatientId(t, i) },
                ct = function() { n.searchMode = !n.searchMode };
            (function() { n.onPageChanged = it;
                n.onPageSizeChanged = rt;
                n.refresh = ft;
                n.search = d;
                n.switchMode = ct;
                n.itemType = "线索追踪";
                ut() })() } } }]);
managementModule.directive("expenditureEditView", ["$log", "$timeout", "practiceSvc", "dataDicSvc", function(n, t, i, r) { "use strict"; return { restrict: "E", replace: !0, templateUrl: "/app/management/views/expenditure/expenditure-edit-view.html", link: function(n, u) { var f = function() { i.getItemTypes("支出支付方式").success(function(t) { var r, i; if (t.unshift({ itemName: "请选择" }), u.find("#payTypeInput").kendoDropDownList({ dataSource: t, filter: "contains", placeholder: "请选择类别", dataTextField: "itemName", dataValueField: "itemName", select: function(t) { var i = this.dataItem(t.item.index());
                                    n.expend.payType = i.itemName } }), r = u.find("#payTypeInput").data("kendoDropDownList"), n.expend.payType)
                            for (i = 0; i < t.length; i++) t[i].itemName == n.expend.payType && r.select(i) }) },
                e = function() { i.getItemTypes("支出类别").success(function(t) { var r, i; if (t.unshift({ itemName: "请选择" }), u.find("#expendTypeInput").kendoDropDownList({ dataSource: t, filter: "contains", placeholder: "请选择类别", dataTextField: "itemName", dataValueField: "itemName", select: function(t) { var i = this.dataItem(t.item.index());
                                    n.expend.expendType = i.itemName } }), r = u.find("#expendTypeInput").data("kendoDropDownList"), n.expend.expendType)
                            for (i = 0; i < t.length; i++) t[i].itemName == n.expend.expendType && r.select(i) }) },
                o = function() { r.currentOfficeWorkProviderDic.load().then(function(t) { var r, f, i; if (t.unshift({ name: "请选择", id: 0 }), u.find("#operatorInput").kendoDropDownList({ dataSource: t, filter: "contains", placeholder: "请选择经办人", dataTextField: "name", dataValueField: "id", select: function(t) { var i = this.dataItem(t.item.index());
                                    n.expend.operatorId = i.id;
                                    n.expend.operatorName = i.name } }), r = u.find("#operatorInput").data("kendoDropDownList"), n.expend.operatorId)
                            for (i = 0; i < t.length; i++) t[i].id == n.expend.operatorId && r.select(i); if (u.find("#principalInput").kendoDropDownList({ dataSource: t, filter: "contains", placeholder: "请选择负责人", dataTextField: "name", dataValueField: "id", select: function(t) { var i = this.dataItem(t.item.index());
                                    n.expend.principalId = i.id;
                                    n.expend.principalName = i.name } }), f = u.find("#principalInput").data("kendoDropDownList"), n.expend.principalId)
                            for (i = 0; i < t.length; i++) t[i].id == n.expend.principalId && f.select(i) }) };
            (function() { n.initExpendPayType = f;
                n.initExpendType = e;
                n.$watch("expend", function() { n.expend && (n.isBrowsed || (f(), e(), o())) }) })();
            t(function() { Ares.centerModal(u.closest(".modal-dialog")) }, 5) } } }]);
managementModule.directive("expenditureHomeView", ["$log", "$timeout", "$filter", "$window", "appNav", "enums", "permissionProvider", "aresModalShelf", function(n, t, i, r, u, f, e, o) { "use strict"; return { restrict: "E", templateUrl: "/app/management/views/expenditure/expenditure-home-view.html", link: function(n) { var t = o,
                i = function() { var n = t.open({ title: "支出设置", template: "<ares3-office-expend-center-page><\/ares3-office-expend-center-page>", customWidth: "1000px" }) },
                r = function() { var r = [new u.TabItem("expendCenter.list", "支出管理", "expend-title", "expendCenter.list"), ],
                        t;
                    n.states = r;
                    window.Ares3 && (t = { permissionCode: "expendCenter.config" }, n.commands = [new Ares.TabCommand("设置", i, "lc-btn lc-btn-primary", 0, t)]) };
            (function() { r();
                n.isAres3 = window.Ares3 })() } } }]);
managementModule.directive("expenditureListView", ["$log", "$timeout", "practiceSvc", "expendSvc", "dataDicSvc", function(n, t, i, r, u) { "use strict"; return { restrict: "E", replace: !0, controller: "ExpenditureListCtrl", templateUrl: "/app/management/views/expenditure/expenditure-list-view.html", link: function(n, t) { var f = function() { i.getItemTypes("支出类别").success(function(i) { i.unshift({ itemName: "全部" });
                        t.find("#expendTypeInput").kendoDropDownList({ dataSource: i, filter: "contains", placeholder: "请选择类别", dataTextField: "itemName", dataValueField: "itemName", select: function(t) { var i = this.dataItem(t.item.index()); if (i.itemName == "全部") { n.criteria.expendType = ""; return } n.criteria.expendType = i.itemName;
                                Ares.sensors.trackDropDownEvent("ExpenditureList", "类别") } }) }) },
                e = function() { i.getItemTypes("支出支付方式").success(function(i) { i.unshift({ itemName: "全部" });
                        t.find("#payTypeInput").kendoDropDownList({ dataSource: i, filter: "contains", placeholder: "请选择类别", dataTextField: "itemName", dataValueField: "itemName", select: function(t) { var i = this.dataItem(t.item.index()); if (i.itemName == "全部") { n.criteria.payType = ""; return } n.criteria.payType = i.itemName;
                                Ares.sensors.trackDropDownEvent("ExpenditureList", "支付方式") } }) }) },
                o = function() { u.currentOfficeWorkProviderDic.load().then(function(i) { i.unshift({ name: "全部", id: 0 });
                        t.find("#operatorInput").kendoDropDownList({ dataSource: i, filter: "contains", placeholder: "请选择经办人", dataTextField: "name", dataValueField: "id", select: function(t) { var i = this.dataItem(t.item.index());
                                n.criteria.operatorId = i.id;
                                Ares.sensors.trackDropDownEvent("ExpenditureList", "经办人") } });
                        t.find("#principalInput").kendoDropDownList({ dataSource: i, filter: "contains", placeholder: "请选择负责人", dataTextField: "name", dataValueField: "id", select: function(t) { var i = this.dataItem(t.item.index());
                                n.criteria.principalId = i.id;
                                Ares.sensors.trackDropDownEvent("ExpenditureList", "负责人") } }) }) },
                s = function() { var t = { criteria: n.criteria, columns: [{ field: "expendTime", title: "时间" }, { field: "operatorName", title: "经办人" }, { field: "principalName", title: "负责人" }, { field: "expendType", title: "支出类别" }, { field: "expendDetail", title: "支出明细" }, { field: "amount", title: "金额" }, { field: "payType", title: "支付方式" }, { field: "notes", title: "备注" }, ] };
                    r.exportExpenditures(t) },
                h = function() { var n = $(window).height() - 380;
                    t.find("#list-body").css("height", n) },
                c = function() { n.criteria = { startTime: null, endTime: null, expendType: "", payType: "", expendDetail: "", operatorId: 0, principalId: 0, pageSize: 15, pageIndex: 1 };
                    n.timeSpan.startDate = null;
                    n.timeSpan.endDate = null;
                    t.find("#principalInput").data("kendoDropDownList").select(0);
                    t.find("#expendTypeInput").data("kendoDropDownList").select(0);
                    t.find("#payTypeInput").data("kendoDropDownList").select(0);
                    t.find("#operatorInput").data("kendoDropDownList").select(0);
                    n.selectDate = "all";
                    n.search() };
            (function() { o();
                f();
                e();
                h();
                n.clear = c;
                n.exportInventoryProduct = s })() } } }]);
managementModule.directive("backupDataContainerView", ["$log", "$timeout", "$q", "$state", "$compile", "moduleOptionProvider", "loginContext", "appNav", "patientNav", function() { return { restrict: "E", controller: "BackupDataContainerCtrl", scope: { reportName: "@" }, templateUrl: "/app/management/views/export/backup-data-container-view.html", link: function(n, t) { var i = function() { n.initReportConfig();
                    n.itemGridOption = n.reportName },
                r = function(n) { return t.find('.pre-defined-columns [column-field="' + n + '"]').html() };
            (function() { n.reservedColumns = ["oper"];
                i();
                n.getColumnTemplate = r })() } } }]);
var management;
(function() { "use strict"; var n = function() {
        function n(n, t, i) { var r = this;
            this.appNav = n;
            this.officeOptionSvc = t;
            this.moduleOptionProvider = i;
            this.templateUrl = "/app/management/views/export/export-home-view.html";
            this.replace = !0;
            this.restrict = "E";
            this.link = function(n) { var t = function() { var t = [];
                    r.moduleOptionProvider.isHealthBureauDataExportEnabled() && t.push(new r.appNav.TabItem("exportCenter.healthBureauDataExport", "机构数据下载", "glyphicon glyphicon-import", "dataExport.healthBureauDataExport"));
                    r.moduleOptionProvider.isHealthBureauDataExportEnabled_Shenzhen() && t.push(new r.appNav.TabItem("exportCenter.healthBureauDataExport_Shenzhen", "深圳机构数据上传", "glyphicon glyphicon-import", "dataExport.healthBureauDataExport"));
                    r.moduleOptionProvider.isBizDataBackupEnabled() && t.push(new r.appNav.TabItem("exportCenter.dataBackup", "数据备份选择", "glyphicon glyphicon-duplicate", "dataExport.bizDataBackup"));
                    n.states = t };
                (function() { t() })() } } return n.$inject = ["appNav", "officeOptionSvc", "moduleOptionProvider"], n }();
    managementModule.directive("exportHomeView", Ares.tsDirective(n)) })(management || (management = {}));
var management;
(function() { "use strict"; var n = function() {
        function n(n, t, i) { var r = this;
            this.$window = n;
            this.$timeout = t;
            this.$interval = i;
            this.templateUrl = "/app/management/views/export/health-bureau-data-export-shenzhen-view.html";
            this.replace = !0;
            this.restrict = "E";
            this.controller = "HealthBureauDataExportShenzhenCtrl";
            this.link = function(n, t) { var u = r,
                    f = [{ field: "rowNum", title: "序号", width: "50px" }, { field: "taskName", title: "说明", width: "200px" }, { field: "startTimeStr", title: "上传时间", width: "120px" }, { field: "resultSummary", title: "上传结果", width: "450px", template: function(n) { var u = "",
                                r, i, t; if (n && n.resultSummary)
                                for (r = n.resultSummary.split("\r\n"), i = 0; i < r.length; i++) t = r[i].replace("StartTime:", "时间范围:["), t = t.replace("00:00:00, EndTime:", " ~ "), t = t.replace(", EndTime:", " ~ ") + "]", u += "<div>" + t + "<\/div>"; return u } }, { field: "stateStr", title: "状态", width: "120px", template: function(n) { return '<span class="' + n.stateClass + '">' + n.stateStr + "<\/span>" } }],
                    i = function() { var i = t.find("#healthBureauDataGrid");
                        i.html(""); var r = i.offset().top,
                            e = u.$window.innerHeight - r - 90,
                            o = i.kendoGrid({ dataSource: n.backgroundTasks, height: e, columns: f, sortable: !1, resizable: !0, reorderable: !0, columnMenu: !1 }).data("kendoGrid") },
                    e = function() { n.searchTask().then(function() { i() }) };
                (function() { n.refreshGrid = i;
                    e() })() } } return n.$inject = ["$window", "$timeout", "$interval"], n }();
    managementModule.directive("healthBureauDataExportShenzhenView", Ares.tsDirective(n)) })(management || (management = {}));
var management;
(function() { "use strict"; var n = function() {
        function n(n, t, i) { var r = this;
            this.$window = n;
            this.$timeout = t;
            this.$interval = i;
            this.templateUrl = "/app/management/views/export/health-bureau-data-export-view.html";
            this.replace = !0;
            this.restrict = "E";
            this.controller = "HealthBureauDataExportCtrl";
            this.link = function(n, t) { var i = r,
                    o = function() { var n = t.find(".taskList"),
                            r = n.offset().top,
                            u = i.$window.innerHeight - r - 90;
                        n.css("height", u) },
                    s = function() { var i = t.find("#healthBureauDepartment").kendoDropDownList({ optionLabel: "请选择", dataTextField: "name", dataValueField: "code", value: n.healthBureauDepartment.code, dataSource: n.healthBureauDepartments }).data("kendoDropDownList");
                        i.value(n.healthBureauDepartment.code) },
                    f = [{ field: "rowNum", title: "序号", width: "50px" }, { field: "taskName", title: "数据文件名", width: "350px" }, { field: "submitTimeStr", title: "提交时间", width: "120px" }, { field: "startTimeStr", title: "生成时间", width: "120px" }, { field: "resultSummary", title: "生成结果", width: "250px" }, { field: "stateStr", title: "状态", width: "120px", template: function(n) { return '<span class="' + n.stateClass + '">' + n.stateStr + "<\/span>" } }, { field: "method", title: "操作", width: "120px", template: function(n) { var t = ""; switch (n.stateStr) {
                                case "生成中":
                                    t = '<span style = "cursor:pointer;color:#BFBFBF"> 下载 <\/span>'; break;
                                case "已下载":
                                    t = '<span style="cursor:pointer;color:#00A6C9" class="download-btn" data-url="' + n.resultLink + '">下载<\/span>'; break;
                                case "已过期":
                                case "已取消":
                                case "下载失败":
                                    t = '<span style="cursor:pointer;color:#00A6C9" class="re-create-btn" data-id="' + n.id + '">重新生成<\/span>' } return t } }, ],
                    u = function() { var r = t.find("#healthBureauDataGrid");
                        r.html(""); var e = r.offset().top,
                            o = i.$window.innerHeight - e - 90,
                            u = r.kendoGrid({ dataSource: n.backgroundTasks, height: o, columns: f, sortable: !1, resizable: !0, reorderable: !0, columnMenu: !1 }).data("kendoGrid");
                        u.table.on("click", ".download-btn", function() { var n = t.find(this).attr("data-url");
                            Ares.download(n) });
                        u.table.on("click", ".re-create-btn", function() { var i = t.find(this).attr("data-id");
                            n.reCreateTask(i) }) },
                    e = function() { n.searchTask().then(function() { u() }) };
                (function() { n.refreshGrid = u;
                    n.getOffice();
                    e();
                    n.getDurationSeconds().then(function(t) { n.setRemainTimeString(t) });
                    n.getHealthBureauVpnAccount().then(function(t) { n.vpnAccount = t });
                    i.$timeout(function() { t.find('[data-toggle="tooltip"]').tooltip() }) })() } } return n.$inject = ["$window", "$timeout", "$interval"], n }();
    managementModule.directive("healthBureauDataExportView", Ares.tsDirective(n)) })(management || (management = {}));
managementModule.directive("followupAutoRuleListView", ["$log", "permissionProvider", "aresNotification", "aresDialog", "managementDialogUtil", "enums", "operationLogUtil", function(n, t, i, r, u, f, e) { "use strict"; return { restrict: "E", controller: "FollowupAutoRuleListCtrl", templateUrl: "/app/management/views/followup/followup-auto-rule-list-view.html", link: function(n) { var o = function() { n.searchFollowupAutoRules().then(function(t) { n.pageIndex = t.data.pageIndex;
                        n.pageSize = t.data.pageSize;
                        n.totalCount = t.data.totalCount;
                        n.pagedFollowupAutoRules = t.data.items;
                        n.pagedFollowupAutoRules.forEach(n => n.isEnabled = !n.isDisabled) }) },
                l = function() { o() },
                a = function() { var t = n.pagedFollowupAutoRules ? n.pagedFollowupAutoRules.length + 1 : 1,
                        i;
                    n.pagedFollowupAutoRules && n.pagedFollowupAutoRules.length > 0 && (t = n.pagedFollowupAutoRules[n.pagedFollowupAutoRules.length - 1].showOrder + 1);
                    i = { showOrder: t, ruleType: f.FollowupRuleType.Rule, ruleSubType: f.FollowupRuleSubType.ApptContent, creationMode: f.FollowupCreationMode.AllAtOnce, timeMode: f.FollowupTimeMode.Absolute, followupRuleConds: [], ruleTemplate: { ruleType: f.FollowupRuleType.Rule, creationMode: f.FollowupCreationMode.AllAtOnce, timeMode: f.FollowupTimeMode.Absolute } };
                    c(i) },
                v = function(t) { n.getFollowupAutoRuleById(t).then(function(n) { c(n) }) },
                y = function(t) { n.getFollowupAutoRuleById(t).then(function(n) { c(n, !1) }) },
                p = function(t) { r.confirm("删除规则", "确定删除自动随访规则“" + t.ruleName + "”").then(function() { n.deleteFollowupAutoRule(t.id).success(function() { o() }).error(function(n) { n.name == "IsExistFKToFollowupRuleIdException" ? i.error("已存在随访运用该模版，不允许删除!") : i.error("删除失败，请重试。") });
                        Ares.sensors.track("ManagementFollowup", { OperationType: "删除自动随访规则" }) }) },
                c = function(n, t) { u.openEditFollowupAutoRuleDialog(n, t).then(function() { o();
                        n.id ? Ares.sensors.track("ManagementFollowup", { OperationType: "修改自动随访规则" }) : Ares.sensors.track("ManagementFollowup", { OperationType: "新增自动随访规则" }) }) },
                s = function(t) { if (n.selectedRow = t, n.pagedFollowupAutoRules.length == 1) { n.elementStates.moveUp.disabled = !0;
                        n.elementStates.moveToTop.disabled = !0;
                        n.elementStates.moveDown.disabled = !0;
                        n.elementStates.moveToBottom.disabled = !0; return } t > 0 && t < n.pagedFollowupAutoRules.length - 1 ? (n.elementStates.moveUp.disabled = !1, n.elementStates.moveToTop.disabled = !1, n.elementStates.moveDown.disabled = !1, n.elementStates.moveToBottom.disabled = !1) : t == n.pagedFollowupAutoRules.length - 1 ? (n.elementStates.moveUp.disabled = !1, n.elementStates.moveToTop.disabled = !1, n.elementStates.moveDown.disabled = !0, n.elementStates.moveToBottom.disabled = !0) : t == 0 && (n.elementStates.moveUp.disabled = !0, n.elementStates.moveToTop.disabled = !0, n.elementStates.moveDown.disabled = !1, n.elementStates.moveToBottom.disabled = !1) },
                h = function(t) { var r, e, h, f, u; if (!_.isUndefined(n.selectedRow)) { if (r = n.pagedFollowupAutoRules, t == "up") e = n.selectedRow - 1, f = r[e], r[e] = r[n.selectedRow], r[n.selectedRow] = f, s(e);
                        else if (t == "top") { for (f = r[n.selectedRow], u = n.selectedRow; u > 0; u--) r[u] = r[u - 1];
                            r[0] = f;
                            s(0) } else if (t == "down") h = n.selectedRow + 1, f = r[h], r[h] = r[n.selectedRow], r[n.selectedRow] = f, s(h);
                        else if (t == "botton") { for (f = r[n.selectedRow], u = n.selectedRow; u < r.length - 1; u++) r[u] = r[u + 1];
                            r[r.length - 1] = f;
                            s(r.length - 1) } r.forEach(function(n, t) { n.showOrder = t + 1 });
                        n.updateFollowupAutoRulesOrder(r).then(null, function() { o();
                            i.error("操作失败，请重试。") }) } },
                w = { moveUp: { text: "上移", disabled: !0, onClick: function() { h("up") } }, moveDown: { text: "下移", disabled: !0, onClick: function() { h("down") } }, moveToTop: { text: "上移至顶", disabled: !0, onClick: function() { h("top") } }, moveToBottom: { text: "下移至底", disabled: !0, onClick: function() { h("botton") } } },
                b = function(t) { t.isDisabled = !t.isEnabled;
                    n.updateFollowupAutoRule(t).then(null, function() { o();
                        i.error("操作失败，请重试。") });
                    Ares.sensors.track("ManagementFollowup", { OperationType: (t.isDisabled ? "禁用" : "启用") + "自动随访规则" }) },
                k = function(n) { var t = n.id;
                    e.viewOperationLog(t, "FollowupRule") };
            (function() { n.listHeight = { height: angular.element(window).height() - 245 };
                n.criteria = { pageIndex: 1, pageSize: 1e5, ruleSubType: "0" };
                n.elementStates = w;
                n.onAddFollowupAutoRule = a;
                n.onEditFollowupAutoRule = v;
                n.onViewFollowupAutoRule = y;
                n.onDeleteFollowupAutoRule = p;
                n.refreshGrid = o;
                n.selectRow = s;
                n.onSwitchChanged = b;
                n.viewOperationLog = k;
                n.isAllowEditAutoRule = t.isAllowed("followup.rule");
                l() })() } } }]);
managementModule.directive("followupConfigView", ["$log", "$timeout", "$window", "aresDialog", function() { "use strict"; return { restrict: "E", controller: "FollowupConfigCtrl", templateUrl: "/app/management/views/followup/followup-config-view.html", link: function() {
            (function() {})() } } }]);
managementModule.directive("followupContentEditView", ["$log", "$timeout", "$window", "aresDialog", function(n, t, i, r) { "use strict"; return { restrict: "E", replace: !0, templateUrl: "/app/management/views/followup/followup-content-edit-view.html", link: function(n, i) { var u = function() { var f = i.find("#contentName").val(),
                    t, e, u; if (!f) { r.info("提示", "请输入名称！"); return } if (t = i.find("#content").val(), !t) { r.info("提示", "请输入内容！"); return } if (t && t.length > 500) { r.info("提示", "内容长度不允许超过500！"); return } if (e = n.followupContent.id, e) { if (u = _.find(n.followupContents, function(n) { return n.id != e && n.name == f }), u) { r.info("提示", "该名称已存在,请重新输入！"); return } } else if (u = _.find(n.followupContents, function(n) { return n.name == f }), u) { r.info("提示", "该名称已存在,请重新输入！"); return } n.save() };
            (function() { n.onSave = u;
                t(function() { Ares.centerModal(i.closest(".modal-dialog")) }, 5) })() } } }]);
managementModule.directive("followupContentListView", ["$log", "$timeout", "aresDialog", "$window", "followupSvc", function(n, t, i, r) { "use strict"; return { restrict: "E", controller: "FollowupContentListCtrl", templateUrl: "/app/management/views/followup/followup-content-list-view.html", link: function(n, u) { var e = Ares.kendoGridUtil(r, n),
                f = null,
                o = function() { var i = $(u).find("#followupContentList");
                    f = i.kendoGrid({ dataSource: { data: n.followupContents }, scrollable: !0, sortable: !0, selectable: "single", model: { id: "id" }, change: function() { var i = this.dataItem(this.select());
                            t(function() { n.selectedItem = i ? i : null }) }, columns: [{ field: "name", title: "随访内容名称", width: "250px" }, { field: "content", title: "内容" }, { template: e.commandTemplate, title: "", width: "140px" }] });
                    f = i.data("kendoGrid") },
                s = function(t) { f ? (f.dataSource.data(n.followupContents), t && h()) : o() },
                h = function() { var t, i;
                    f && n.selectedItem && (t = f.dataSource.get(n.selectedItem.id), t && (i = f.element.find("tbody>tr[data-uid=" + t.uid + "]"), i && f.select(i))) },
                c = [{ text: "修改", action: "update", icon: "glyphicon glyphicon-pencil" }, { text: "删除", action: "delete", icon: "glyphicon glyphicon-remove" }],
                l = function(t, r, u) { n.$apply(function() { var t = _.find(n.followupContents, function(n) { return n.id == u }); switch (r) {
                            case "update":
                                n.update(t); break;
                            case "delete":
                                i.confirm("信息", "确定要删除吗！").then(function() { n.del(u) }) } }) };
            (function() { n.listHeight = { height: angular.element(window).height() - 245 };
                n.commands = c;
                n.onCommandClick = l;
                n.refreshGrid = s })() } } }]);
managementModule.directive("followupHomeView", ["$log", "$timeout", "$filter", "$window", "appNav", "enums", "permissionProvider", function(n, t, i, r, u) { "use strict"; return { restrict: "E", templateUrl: "/app/management/views/followup/followup-home-view.html", link: function(n) { var t = function() { var t = [new u.TabItem("followupCenter.list", "随访记录", "glyphicon glyphicon-list-alt", "followup.list"), new u.TabItem("followupCenter.last", "最近随访", "glyphicon glyphicon-cog", "followup.last"), new u.TabItem("followupCenter.content", "随访内容", "icon-notebook", "followup.content"), new u.TabItem("followupCenter.result", "随访结果", "icon-notebook", "followup.result"), new u.TabItem("followupCenter.template", "随访节点模版", "glyphicon glyphicon-cog", "followup.config"), new u.TabItem("followupCenter.autoRule", "自动随访规则", "glyphicon glyphicon-cog", "followup.rule"), ];
                n.states = t };
            (function() { t() })() } } }]);
managementModule.directive("followupResultListView", ["$log", "$timeout", "aresDialog", "$window", "followupSvc", function(n, t, i, r) { "use strict"; return { restrict: "E", controller: "FollowupResultListCtrl", templateUrl: "/app/management/views/followup/followup-result-list-view.html", link: function(n, u) { var e = Ares.kendoGridUtil(r, n),
                f = null,
                o = function() { var i = $(u).find("#followupContentList");
                    f = i.kendoGrid({ dataSource: { data: n.followupContents }, scrollable: !0, sortable: !0, selectable: "single", model: { id: "id" }, change: function() { var i = this.dataItem(this.select());
                            t(function() { n.selectedItem = i ? i : null }) }, columns: [{ field: "name", title: "随访结果名称", width: "150px" }, { field: "content", title: "内容" }, { template: e.commandTemplate, title: "", width: "140px" }] });
                    f = i.data("kendoGrid") },
                s = function(t) { f ? (f.dataSource.data(n.followupContents), t && h()) : o() },
                h = function() { var t, i;
                    f && n.selectedItem && (t = f.dataSource.get(n.selectedItem.id), t && (i = f.element.find("tbody>tr[data-uid=" + t.uid + "]"), i && f.select(i))) },
                c = [{ text: "修改", action: "update", icon: "glyphicon glyphicon-pencil" }, { text: "删除", action: "delete", icon: "glyphicon glyphicon-remove" }],
                l = function(t, r, u) { n.$apply(function() { var f = _.find(n.followupContents, function(n) { return n.id == u }); switch (r) {
                            case "update":
                                n.update(f); break;
                            case "delete":
                                i.confirm("信息", "确定要删除吗！").then(function() { n.del(u) }) } Ares.sensors.trackGridEvent(t, "FollowResult", r, ["update", "delete"]) }) };
            (function() { n.listHeight = { height: angular.element(window).height() - 245 };
                n.commands = c;
                n.onCommandClick = l;
                n.refreshGrid = s })() } } }]);
managementModule.directive("followupRuleEditView", ["$log", "$timeout", "$window", "aresDialog", function(n, t, i, r) { "use strict"; return { restrict: "E", replace: !0, templateUrl: "/app/management/views/followup/followup-rule-edit-view.html", link: function(n, i) { var e = function() { var t = i.find("#ruleName").val(),
                        f, u, e; if (t = $.trim(t), !t) { r.info("提示", "请输入名称！"); return } if (t && t.length > 20) { r.info("提示", "内容长度不允许超过20！"); return } if (f = n.followupRule.id, f) { if (u = _.find(n.followupRules, function(n) { return n.id != f && n.ruleName == t }), u) { r.info("提示", "该名称已存在,请重新输入！"); return } } else if (u = _.find(n.followupRules, function(n) { return n.ruleName == t }), u) { r.info("提示", "该名称已存在,请重新输入！"); return } if (!n.followupRule.timeMode == undefined) { r.info("提示", "请选择随访计划时间模式!"); return } if (!n.followupRule.creationMode == undefined) { r.info("提示", "请选择创建随访计划方式!"); return } if (n.followupRule.followupRuleActions.length <= 0) { r.info("提示", "保存前，请添加至少一个随访节点!"); return } if (e = o(), e) { r.info("提示", e); return } n.save() },
                o = function() { for (var t, i = "", u = [], f = n.todayDate, r = 0; r < n.followupRule.followupRuleActions.length; r++) { if (t = n.followupRule.followupRuleActions[r], t.afterChangeDate > f) f = t.afterChangeDate;
                        else { i = r == 0 ? "节点内容中第1行的节点必须大于0 !" : "节点内容中第" + t.showOrder + "行节点必须大于第" + (t.showOrder - 1) + "行节点!"; break } if (!t.followupContentId) { i = "请选择随访内容模版"; break } if (_.contains(u, t.dueTime + t.unit)) { i = "节点不能重复"; break } else u.push(t.dueTime + t.unit);
                        t.delay = t.dueTime + t.unit;
                        t.actorJob = t.actorJob || null } if (i) return i },
                u = function() { var t = n.todayDate,
                        i = 1; return n.followupRule ? (angular.forEach(n.followupRule.followupRuleActions, function(r) { r.afterChangeDate = r.unit === "天" ? moment(t).add(r.dueTime, "day").format("YYYY-MM-DD") : moment(t).add(r.dueTime, "month").format("YYYY-MM-DD");
                        n.followupRule.timeMode != 1 && (t = r.afterChangeDate);
                        r.showOrder = i;
                        i++ }), { lastDate: t, maxIndex: i }) : { lastDate: t, maxIndex: i } },
                s = function(t) { var i = _.findIndex(n.followupRule.followupRuleActions, function(n) { return n.showOrder == t });
                    n.followupRule.followupRuleActions.splice(i, 1);
                    u() },
                h = function() { var t = u(),
                        i = moment(t.lastDate).add(1, "days").format("YYYY-MM-DD"),
                        r = { dueTime: "1", unit: "天", showOrder: t.maxIndex, afterChangeDate: i, followupContentId: 0 };
                    n.followupRule.followupRuleActions.push(r);
                    f("itemName" + t.maxIndex, n.followupContents, !0);
                    f("actorJob" + t.maxIndex, n.jobDic, !0) },
                f = function(n, r, u) { t(function() { i.find("#" + n).kendoDropDownList({ optionLabel: "请选择", dataTextField: "name", dataValueField: "id", dataSource: r, enable: u }) }, 10) },
                c = function() { u();
                    t(function() { i.find("#chargeItem_td").attr("title", n.chargeItemNames);
                        i.find("#chargeCategory_td").attr("title", n.chargeTypeNames);
                        i.find("#transactioncode_td").attr("title", n.apptItemNames);
                        i.find("#apptCategory_td").attr("title", n.apptTypeNames);
                        _.each(n.followupRule.followupRuleActions, function(t) { f("itemName" + t.showOrder, n.followupContents, !0);
                            f("actorJob" + t.showOrder, n.jobDic, !0) }) }, 100) },
                l = function(n) { n.dueTime === "0" && (n.dueTime = "1");
                    u() };
            (function() { n.onSave = e;
                n.onDelRow = s;
                n.onAddRow = h;
                n.initView = c;
                n.changeDate = l;
                t(function() { Ares.centerModal(i.closest(".modal-dialog")) }, 5);
                n.$watch("followupRule.timeMode", function() { u() }) })() } } }]);
managementModule.directive("followupRuleListView", ["$log", "$timeout", "$window", "aresDialog", function(n, t, i, r) { "use strict"; return { restrict: "E", controller: "FollowupRuleListCtrl", templateUrl: "/app/management/views/followup/followup-rule-list-view.html", link: function(n, t) { var e = Ares.kendoGridUtil(i, n),
                u = null,
                o = function() { var n = this;
                    $(t).find("#followupRuleList table tbody tr").each(function(t, i) { var r = n.dataItem(i);
                        r.isDefault && $(this).find("td .btn-group").find('button[data-action="delete"]').remove();
                        r.isDisabled ? ($(this).find("td .btn-group").find('button[data-action="disable"]').remove(), $(this).find("td .btn-group").find('button[data-action="update"]').remove()) : $(this).find("td .btn-group").find('button[data-action="enable"]').remove() }) },
                s = function() { var i = $(t).find("#followupRuleList");
                    u = i.kendoGrid({ dataSource: { data: n.followupRules }, dataBound: o, scrollable: !0, sortable: !1, selectable: "single", columns: [{ field: "showOrder", title: "匹配顺序", width: "60px" }, { field: "ruleName", title: "名称", width: "150px" }, { field: "isDisabledStr", title: "是否启用", width: "70px" }, { field: "isDefaultStr", title: "类型", width: "70px" }, { template: e.commandTemplate, title: "", width: "140px" }] });
                    u = i.data("kendoGrid") },
                h = [{ text: "修改", action: "update" }, { text: "禁用", action: "disable" }, { text: "启用", action: "enable" }, { text: "删除", action: "delete" }, ],
                c = function() { var i, t, r;
                    u ? (u.dataSource.data(n.followupRules), n.selectedItem && (i = u.dataSource, t = i.get(n.selectedItem.id), t && (r = u.element.find("tbody>tr[data-uid=" + t.uid + "]"), u.select(r)), n.selectedItem = t)) : s() },
                l = function(t, i, u) { n.$apply(function() { var e = _.find(n.followupRules, function(n) { return n.id == u }),
                            f = angular.copy(e); switch (i) {
                            case "update":
                                n.update(f); break;
                            case "delete":
                                r.confirm("信息", "确定要删除吗！").then(function() { n.del(u) }); break;
                            case "disable":
                                n.disableFollowupRule(f); break;
                            case "enable":
                                n.enableFollowupRule(f) } Ares.sensors.trackGridEvent(t, "FollowupRuleList") }) },
                f = function() { var t = u.select();
                    n.selectedRowIndex = $("tr", u.tbody).index(t) },
                a = function() { f(); var i = n.followupRules[n.selectedRowIndex],
                        t = n.followupRules[n.selectedRowIndex - 1];
                    t && n.upItem(i, t) },
                v = function() { f(); var i = n.followupRules[n.selectedRowIndex],
                        t = n.followupRules[n.selectedRowIndex + 1];
                    t && n.downItem(i, t) },
                y = function(t) { u.dataSource.data(n.followupRules);
                    u.select("#followupRuleList tr:eq(" + (t - 1) + ")") },
                p = function(t) { u.dataSource.data(n.followupRules);
                    u.select("#followupRuleList tr:eq(" + (t + 1) + ")") };
            (function() { n.up = a;
                n.down = v;
                n.refreshUpDownGrid = y;
                n.refreshDownGrid = p;
                n.startBtnDisable = !0;
                n.endBtnDisable = !0;
                n.commands = h;
                n.onCommandClick = l;
                n.refreshGrid = c })() } } }]);
managementModule.directive("followupTemplateListView", ["$log", "$timeout", "aresNotification", "aresDialog", "managementDialogUtil", "enums", "operationLogUtil", function(n, t, i, r, u, f, e) { "use strict"; return { restrict: "E", controller: "FollowupTemplateListCtrl", templateUrl: "/app/management/views/followup/followup-template-list-view.html", link: function(n) { var t = function() { n.searchFollowupTemplates().then(function(t) { n.pageIndex = t.data.pageIndex;
                        n.pageSize = t.data.pageSize;
                        n.totalCount = t.data.totalCount;
                        n.pagedFollowupTemplates = t.data.items;
                        n.pagedFollowupTemplates.forEach(n => n.isEnabled = !n.isDisabled) }) },
                c = function() { t() },
                l = function() { var t = n.pagedFollowupTemplates.length + 1,
                        i = { showOrder: t, ruleType: f.FollowupRuleType.Template, creationMode: f.FollowupCreationMode.AllAtOnce, timeMode: f.FollowupTimeMode.Absolute, actions: [] };
                    h(i) },
                a = function(t) { n.getFollowupTemplateById(t).then(function(n) { h(n) }) },
                v = function(u) { r.confirm("删除模板", "确定删除随访模板“" + u.ruleName + "”").then(function() { n.deleteFollowupTemplate(u.id).success(function() { t() }).error(function(n) { n.name == "IsExistFKToFollowupRuleIdException" ? i.error("已存在随访运用该模版，不允许删除!") : i.error("删除失败，请重试。") });
                        Ares.sensors.track("ManagementFollowup", { OperationType: "删除随访模板" }) }) },
                h = function(n) { u.openEditFollowupTemplateDialog(n).then(function() { t();
                        n.id == null ? Ares.sensors.track("ManagementFollowup", { OperationType: "新增随访模板" }) : Ares.sensors.track("ManagementFollowup", { OperationType: "修改随访模板" }) }) },
                o = function(t) { if (n.selectedRow = t, n.pagedFollowupTemplates.length == 1) { n.elementStates.moveUp.disabled = !0;
                        n.elementStates.moveToTop.disabled = !0;
                        n.elementStates.moveDown.disabled = !0;
                        n.elementStates.moveToBottom.disabled = !0; return } t > 0 && t < n.pagedFollowupTemplates.length - 1 ? (n.elementStates.moveUp.disabled = !1, n.elementStates.moveToTop.disabled = !1, n.elementStates.moveDown.disabled = !1, n.elementStates.moveToBottom.disabled = !1) : t == n.pagedFollowupTemplates.length - 1 ? (n.elementStates.moveUp.disabled = !1, n.elementStates.moveToTop.disabled = !1, n.elementStates.moveDown.disabled = !0, n.elementStates.moveToBottom.disabled = !0) : t == 0 && (n.elementStates.moveUp.disabled = !0, n.elementStates.moveToTop.disabled = !0, n.elementStates.moveDown.disabled = !1, n.elementStates.moveToBottom.disabled = !1) },
                s = function(r) { var u, s, h, e, f; if (!_.isUndefined(n.selectedRow)) { if (u = n.pagedFollowupTemplates, r == "up") s = n.selectedRow - 1, e = u[s], u[s] = u[n.selectedRow], u[n.selectedRow] = e, o(s);
                        else if (r == "top") { for (e = u[n.selectedRow], f = n.selectedRow; f > 0; f--) u[f] = u[f - 1];
                            u[0] = e;
                            o(0) } else if (r == "down") h = n.selectedRow + 1, e = u[h], u[h] = u[n.selectedRow], u[n.selectedRow] = e, o(h);
                        else if (r == "botton") { for (e = u[n.selectedRow], f = n.selectedRow; f < u.length - 1; f++) u[f] = u[f + 1];
                            u[u.length - 1] = e;
                            o(u.length - 1) } u.forEach(function(n, t) { n.showOrder = t + 1 });
                        n.updateFollowupTemplatesOrder(u).then(null, function() { t();
                            i.error("操作失败，请重试。") }) } },
                y = { moveUp: { text: "上移", disabled: !0, onClick: function() { s("up") } }, moveDown: { text: "下移", disabled: !0, onClick: function() { s("down") } }, moveToTop: { text: "上移至顶", disabled: !0, onClick: function() { s("top") } }, moveToBottom: { text: "下移至底", disabled: !0, onClick: function() { s("botton") } } },
                p = function(r) { r.isDisabled = !r.isEnabled;
                    n.updateFollowupTemplate(r).then(null, function() { t();
                        i.error("操作失败，请重试。") });
                    Ares.sensors.track("ManagementFollowup", { OperationType: (r.isDisabled ? "禁用" : "启用") + "随访模板" }) },
                w = function(n) { var t = n.id;
                    e.viewOperationLog(t, "FollowupRule") };
            (function() { n.listHeight = { height: angular.element(window).height() - 245 };
                n.criteria = { pageIndex: 1, pageSize: 1e5 };
                n.elementStates = y;
                n.onAddFollowupTemplate = l;
                n.onEditFollowupTemplate = a;
                n.onDeleteFollowupTemplate = v;
                n.refreshGrid = t;
                n.selectRow = o;
                n.onSwitchChanged = p;
                n.viewOperationLog = w;
                c() })() } } }]);
managementModule.directive("lastFollowupReportView", ["$log", "$timeout", "officeOptionSvc", "$window", "appNav", "gridOptionUtil", "enums", "permissionProvider", "patientSvc", "reportSvc", "providerSvc", function(n, t, i, r, u, f, e, o, s, h, c) { "use strict"; return { restrict: "E", replace: !0, controller: "LastFollowupReportCtrl", templateUrl: "/app/management/views/followup/last-followup-report-view.html", scope: { officeId: "=" }, link: function(n, t) { var o = Ares.kendoGridUtil(r, n),
                i = null;
            n.columns = [{ field: "patientName", title: "患者姓名", width: "50px", template: kendo.template($("#followuptemplate").html()) }, { field: "privateId", title: "病历号", width: "60px" }, { field: "mobile", title: "患者手机号", width: "60px" }, { field: "lastVisitDateTimeStr", title: "上次随访时间", width: "60px" }, { field: "lastOtherProviderName", title: "上次随访人", width: "60px" }, { field: "lastVisitContent", title: "上次随访内容", width: "60px" }, { field: "visitDateTimeStr", title: "下次随访时间", width: "60px" }, { field: "otherProviderName", title: "下次随访人", width: "60px" }, { field: "visitContent", title: "下次随访内容", width: "60px" }, { template: o.commandTemplate, title: "", width: "80px" }];
            r.FollowupPatientCtrl_goToPatient = function(n) { var t = $(n).closest("tr"),
                    i = $("#lastFollowupList").data("kendoGrid"),
                    r = i.dataItem(t); return u.goToPatient(r.patientId), !1 };
            $(".isHideData").hide();
            $("#daysBeforeTodayInput").change(function() { $("#daysBeforeTodayInput").val() == "自定义" ? $(".isHideData").show() : $(".isHideData").hide() }); var e = function() { var u = $(window).height() - 148 - (window.Ares3 ? 40 : 0),
                        r;
                    t.find("#lastFollowupList").html("");
                    i = t.find("#lastFollowupList").kendoGrid({ dataSource: { transport: { read: function(t) { n.pageIndex = t.data.page || 1;
                                    n.pageSize = t.data.pageSize || 15;
                                    t.data.sort && t.data.sort.length > 0 ? (n.sortField = t.data.sort[0].field, n.isAscending = t.data.sort[0].dir == "asc" ? !0 : !1) : (n.sortField = null, n.isAscending = null);
                                    t.data.pageSize ? n.initialize ? n.init().then(function(i) { n.initialize = !1;
                                        t.success(i) }) : n.refresh().then(function(n) { t.success(n) }) : t.success({ totalCount: 0, items: [] }) } }, schema: { data: "items", total: "totalCount" }, pageSize: 10, serverPaging: !0, serverSorting: !0, serverFiltering: !0 }, dataBound: function() { var n = this;
                            $(t).find("#lastFollowupList table tbody tr").each(function() {}) }, height: u, pageable: f.pageable, scrollable: !0, selectable: "single", sortable: !0, columns: n.columns }).data("kendoGrid");
                    r = [{ field: "visitDateTime", dir: "desc" }];
                    i.dataSource.sort(r) },
                s = [{ text: "随访记录", action: "goToFollow" }, { text: "新建随访", action: "create" }],
                l = function(t) { return _.find(n.followupPatList, function(n) { return n.id == t }) },
                a = function() { c.getOtherProvider().success(function(i) { i.splice(0, 0, { id: 0, name: "全部" });
                        t.find("#otherProvider").kendoDropDownList({ dataSource: i, dataTextField: "name", dataValueField: "id", select: function(t) { var i = this.dataItem(t.item.index());
                                n.criteria.providerId = i.id } }).data("kendoDropDownList");
                        t.find("#lastOtherProvider").kendoDropDownList({ dataSource: i, dataTextField: "name", dataValueField: "id", select: function(t) { var i = this.dataItem(t.item.index());
                                n.criteria.lastProviderId = i.id } }).data("kendoDropDownList") }) },
                v = function(t, i, r) { n.$apply(function() { var t = l(r); switch (i) {
                            case "goToFollow":
                                u.goToFollowup(t.patientId); break;
                            case "create":
                                n.create(t.patientId) } }) },
                y = function() { if (i) { var n = t.find(".k-textbox").val() || 1;
                        i.dataSource.page(n) } else e() },
                p = function() { var t, r, u;
                    i && (t = i.columns, n.setCriteria(), r = n.criteria, u = { criteria: r, columns: t }, h.exportLastFollowupReport(u)) },
                w = function() { e() };
            (function() { n.exportFollowUp = p;
                n.commands = s;
                n.onCommandClick = v;
                n.refreshGrid = y;
                w();
                a();
                n.$on("$destroy", function() { delete r.FollowupPatientCtrl_goToPatient }) })() } } }]);
managementModule.directive("groupAutoRevisitRuleView", ["$log", "$timeout", "$q", "$state", "aresNotification", "loginContext", "gridOptionUtil", "dataDicSvc", "aresDialog", "enums", "eventAggregator", function(n, t, i, r, u, f, e, o, s) { "use strict"; return { restrict: "E", controller: "GroupAutoRevisitRuleCtrl", templateUrl: "/app/management/views/group-revisit/group-auto-revisit-rule-view.html", link: function(n, i) { var e, o, h, c, a = function() { e = i.find("#actor").kendoDropDownList({ optionLabel: "请选择", dataSource: [{ name: "网电咨询师", value: "PatientOnlineConsultant" }, ], dataTextField: "name", dataValueField: "value", value: "", filter: "contains", change: function(i) { var r = i.sender.value();
                            n.selectedRule.followupRuleActions[0].actor = r;
                            t(function() { n.$apply() }) } }).data("kendoDropDownList") },
                v = function(r) { var u = [];
                    _.each(n.defaultRuleNames, function(t) { if (r === !0) { var i = _.find(n.revisitRules, { ruleName: t });
                            i || u.push(t) } else u.push(t) });
                    u.push("咨询成交意愿");
                    o = i.find("#ruleMatchKey").kendoDropDownList({ optionLabel: "请选择", dataSource: u, value: "", change: function(i) { var r = i.sender.value();
                            n.selectedRule.ruleMatchKey = r;
                            n.isDefaultRule = _.contains(n.defaultRuleNames, r);
                            n.selectedRule.isDefault = n.isDefaultRule;
                            t(function() { n.$apply() }) } }).data("kendoDropDownList") },
                y = function() { h = i.find("#ruleMatchCondition").kendoDropDownList({ optionLabel: "请选择", dataSource: ["等于"], value: "", change: function(i) { var r = i.sender.value();
                            n.selectedRule.ruleMatchCondition = r;
                            t(function() { n.$apply() }) } }).data("kendoDropDownList") },
                p = function() { c = i.find("#ruleMatchValue").kendoDropDownList({ optionLabel: "请选择", dataSource: n.intentions, dataTextField: "itemName", dataValueField: "itemName", value: "", change: function(i) { var r = i.sender.value();
                            n.selectedRule.ruleMatchValue = r;
                            t(function() { n.$apply() }) } }).data("kendoDropDownList") },
                w = function() { a();
                    y();
                    p() },
                b = function(t) { var i = t.ruleName.split("#");
                    i.length == 3 ? (t.ruleMatchKey = i[0], t.ruleMatchCondition = i[1], t.ruleMatchValue = i[2]) : (t.ruleMatchKey = t.ruleName, t.ruleMatchCondition = "", t.ruleMatchValue = "");
                    n.selectedRule = t;
                    n.oldRule = angular.copy(t);
                    e.value(t.followupRuleActions[0].actor);
                    o.value(t.ruleMatchKey);
                    h.value(t.ruleMatchCondition);
                    c.value(t.ruleMatchValue);
                    n.isDefaultRule = _.contains(n.defaultRuleNames, t.ruleMatchKey) },
                f = function() { var t = _.max(n.revisitRules, "showOrder"),
                        i = t ? t.showOrder ? t.showOrder : 0 : 0; return { id: 0, ruleName: "", ruleMatchKey: "", ruleMatchCondition: "", ruleMatchValue: "", followupType: 1, isDefault: !1, isDisabled: !1, followupRuleConds: [{ condType: "", condValue: "" }], followupRuleActions: [{ actor: "", followupContentId: 0, delay: "" }], revisitContent: { content: "", followupType: 1, type: "内容", name: "", id: 0 }, showOrder: i + 1 } },
                k = function() { n.selectedRule.isDisabled = !n.selectedRule.isDisabled },
                d = function() { var t, i, r; if (Ares.ensureNotDuplicated("OnRevisitRuleSaved")) { if (t = n.selectedRule, i = t.ruleMatchKey, n.isDefaultRule) { if (!t.ruleMatchKey) { s.warn("提示", "请选择事件名称！"); return } } else { if (!t.ruleMatchKey || !t.ruleMatchCondition || !t.ruleMatchValue) { s.warn("提示", "请选择完整的事件名称！"); return } i = t.ruleMatchKey + "#" + t.ruleMatchCondition + "#" + t.ruleMatchValue } if (r = _.find(n.revisitRules, { ruleName: i }), r && r.id != t.id) { s.warn("提示", "选择的事件已经存在，请重新选择！"); return } if (!t.followupRuleConds[0].condValue || t.followupRuleConds[0].condValue == "null") return s.warn("提示", "请输入执行时间"), !1; if (t.followupRuleActions[0].actor != "PatientOnlineConsultant") return s.warn("提示", "请选择回访角色"), !1; if (!t.revisitContent.content) return s.warn("提示", "请输入回访备注"), !1;
                        t.ruleName = i;
                        t.revisitContent.name = i;
                        n.save(t) } },
                l = function(t, i) { angular.forEach(n.revisitRules, function(n) { n.selected = n.id == t.id }); var r = angular.copy(t);
                    v(i);
                    b(r) },
                u = function(t, i) { n.isChanged && n.selectedRule && n.selectedRule.id == t.id || (n.isChanged ? s.confirm("确认提示", "编辑数据还没有保存，离开编辑界面数据将丢失，是否离开？").then(function() { n.isChanged = !1;
                        r.current._hasConfirmed = !0;
                        l(t, i) }) : l(t, i)) },
                g = function() { var n = f();
                    u(n, !0) },
                nt = function() { var t = "确认删除【" + n.selectedRule.showName + "】回访规则?";
                    s.confirm("确认提示", t).then(function() { n.deleteRule(n.selectedRule.id).then(function() { var t = null;
                            t = n.revisitRules && n.revisitRules.length > 0 ? n.revisitRules[0] : f();
                            u(t) }) }) };
            (function() { n.isChanged = !1;
                n.defaultRuleNames = ["到店未成交", "预约未到店"];
                n.onSelectedRule = u;
                n.setEnable = k;
                n.onSave = d;
                n.onDelete = nt;
                n.onAdd = g;
                n.initData().then(function() { var t = null;
                    t = n.revisitRules && n.revisitRules.length > 0 ? n.revisitRules[0] : f();
                    w();
                    u(t) });
                n.$watchGroup(["selectedRule.isDisabled", "selectedRule.ruleMatchKey", "selectedRule.ruleMatchCondition", "selectedRule.ruleMatchValue", "selectedRule.revisitContent.content", "selectedRule.followupRuleConds[0].condValue", "selectedRule.followupRuleActions[0].actor"], function() { n.selectedRule && n.selectedRule.followupRuleConds && n.selectedRule.followupRuleConds.length > 0 && (n.selectedRule.followupRuleConds[0].condValue = n.selectedRule.followupRuleConds[0].condValue + "");
                    _.isEqual(n.oldRule, n.selectedRule) ? (n.isChanged = !1, r.current._hasConfirmed = !0) : (n.isChanged = !0, r.current._hasConfirmed = !1) }) })() } } }]);
managementModule.directive("groupRevisitHomeView", ["$log", "$timeout", "$filter", "$window", "appNav", "enums", "permissionProvider", "practiceSvc", function(n, t, i, r, u) { "use strict"; return { restrict: "E", templateUrl: "/app/management/views/group-revisit/group-revisit-home-view.html", link: function(n) { var t = function() { var t = [new u.TabItem("groupRevisitCenter.list", "回访记录", "icon-notebook", "ReturnVisitFolder.list"), new u.TabItem("groupRevisitCenter.autoRevisitRule", "自动回访规则", "glyphicon glyphicon-cog", "patientMgmt.autoRevisitRule"), ];
                n.states = t };
            (function() { t() })() } } }]);
managementModule.directive("groupRevisitListView", ["$log", "$timeout", "$q", "$window", "apptUtil", "appNav", "officeOptionSvc", "aresNotification", "loginContext", "localCache", "sessionCache", "gridOptionUtil", "dataDicSvc", "aresDialog", "dashboardSvc", "practiceSvc", "patientUtil", "enums", "eventAggregator", "revisitSvc", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y, p, w, b, k, d) { "use strict"; return { restrict: "E", controller: "GroupRevisitListCtrl", templateUrl: "/app/management/views/group-revisit/group-revisit-list-view.html", link: function(n, u) { var p = Ares.kendoGridUtil(r, n),
                y = null,
                o = [],
                k = ["sexStr", "ageStr", "officeName", "planTimeStr", "recordCreatedTimeStr", "recordCreatedUserStr"],
                kt = c.getCache(c.keys.PageSize),
                v = h.getCache(h.keys.GroupRevisitListFields),
                g = function(n) { return o.indexOf(n) >= 0 },
                nt = function() { var n = v.loadObject();
                    o = n instanceof Array ? n : k },
                tt = function() { n.columns = [{ field: "rowNumber", title: " ", sortable: !1, index: 0, code: "index", width: "32px", template: "<span class='row-number'><\/span>", attributes: { style: "padding: 0" } }, { field: "patientName", title: "姓名", width: "120px" }, { field: "sexStr", title: "性别", width: "80px" }, { field: "ageStr", title: "年龄", width: "80px" }, { field: "mobile", title: "手机", width: "120px" }, { field: "privateId", title: "病历号", width: "150px" }, { field: "officeName", title: "就诊门店", width: "150px" }, { field: "visitorName", title: "回访人", width: "120px" }, { field: "visitTimeStr", title: "回访时间", width: "180px" }, { field: "method", title: "沟通方式", width: "150px" }, { field: "planTimeStr", title: "计划时间", width: "120px" }, { field: "recordCreatedTimeStr", title: "创建日期", width: "150px" }, { field: "recordCreatedUserStr", title: "创建人", width: "150px" }, { field: "type", title: "回访类型", width: "120px" }, { field: "transactionItems", title: "回访项目", width: "120px" }, { field: "content", title: "咨询内容", width: "120px" }, { field: "stateStr", title: "回访状态", width: "120px" }, { field: "notes", title: "备注", width: "120px" }, { field: "satisfaction", title: "满意度", width: "120px" }, ]; var t = i.defer(),
                        r = s.officeId,
                        u = e.optionKeys.OnlineConsultCreateInfoFieldsConfig; return e.getOfficeOptionByOfficeId(u, r).then(function(i) { var r = e.optionDefaultValues.OnlineConsultCreateInfoFieldsDefaultConfig,
                            u;
                        i && (r = _.isString(i) ? JSON.parse(i) : i);
                        u = _.filter(r, function(n) { return !n.isEnabled });
                        n.columns = _.filter(n.columns, function(n) { var t = n.field,
                                i; switch (t) {
                                case "visitTimeStr":
                                    t = "visitTime"; break;
                                case "transactionItems":
                                    t = "revisitItems"; break;
                                case "stateStr":
                                    t = "state"; break;
                                case "notes":
                                    t = "revisitNotes" } return i = _.find(u, function(n) { return t == n.name }), i === undefined });
                        t.resolve() }), t.promise },
                it = function() { var i = this,
                        r = i.element,
                        t = r.find(".k-grid-header"),
                        f = t.find(".k-header-column-menu:gt(0)").length;
                    f > 0 && (t.find(".k-header-column-menu:gt(0)").remove(), t.find(".k-header:gt(0)").each(function(n, t) { var i = $(t).find("a");
                        i.css("margin-right", "0") }));
                    $(u).find("#groupRevisitList table tbody tr").each(function(t, r) { var f = i.dataItem(r),
                            e, t;
                        f.state == 0 ? f.visitorId == s.providerId && f.recordCreatedUser != s.userId ? $("td .edit-command", r).remove() : f.visitorId != s.providerId && f.recordCreatedUser == s.userId && $("td .execute-command", r).remove() : $("td .execute-command", r).remove();
                        e = u.find("#groupRevisitList").data("kendoGrid");
                        t = $(this).index() + 1 + n.pageSize * (n.pageIndex - 1);
                        $("td .row-number", r).html(t) }) },
                l = null,
                f = function() { n.refreshRevisit().then(function(t) { n.updateCount();
                        l = angular.copy(n.columns);
                        l.forEach(function(n) { n.hidden = g(n.field) });
                        u.find("#groupRevisitList").html(""); var i = u.find("#groupRevisitListView"),
                            r = u.find("#groupRevisitListHeader"),
                            f = u.find("#groupRevisitListFooter"),
                            e = i.height() - r.height() - f.height() - 20,
                            s = u.find("#groupRevisitList");
                        l.push({ template: p.commandTemplate, title: "", width: "160px" });
                        y = s.kendoGrid({ excel: { allPages: !0 }, dataSource: { data: t.items }, height: e, model: { id: "id" }, columns: l, dataBound: it, sortable: !0, resizable: !0, reorderable: !0, columnMenu: !0, columnShow: function(n) { o = _.without(o, n.column.field);
                                v.saveObject(o);
                                Ares.DockGridColMenuPos(n.sender) }, columnMenuInit: function(n) { n.container.find(".k-sort-asc").remove();
                                n.container.find(".k-sort-desc").remove(); var t = $(n.container).find(".k-menu-group");
                                t.find("li").each(function(n, t) { var i = $(t).text();
                                    i == " " && $(t).remove() }) }, columnHide: function(n) { o.push(n.column.field);
                                v.saveObject(o);
                                Ares.DockGridColMenuPos(n.sender) }, columnReorder: function(n) { Ares.DockGridColMenuPos(n.sender) } }).data("kendoGrid") }) },
                rt = function() { var i = u.find("#revisitState").kendoDropDownList({ dataSource: [{ name: "全部", value: -1 }, { name: "待计划", value: 0 }, { name: "已完成", value: 1 }, { name: "未成功", value: 2 }, { name: "已取消", value: 3 }, ], dataTextField: "name", dataValueField: "value", template: "#: name # ", valueTemplate: "#: name #", select: function(i) { var r = this;
                            t(function() { n.revisitState = r.dataItem(i.item)[r.options.dataValueField];
                                f() });
                            Ares.sensors.trackDropDownEvent("GroupRevisitList", "回访状态") } }).data("kendoDropDownList") },
                ut = function() { f() },
                ft = [{ text: "编辑", action: "update", icon: "glyphicon-pencil", className: "edit-command" }, { text: "执行", action: "execute", icon: "glyphicon glyphicon-ok", className: "execute-command" }, { text: "删除", action: "delete", icon: "glyphicon glyphicon-trash", className: "delete-command" }, ],
                et = function(t) { return _.find(n.pageData.items, function(n) { return n.id == t }) },
                ot = function(t, i, r) { var u = et(r);
                    n.$apply(function() { switch (i) {
                            case "update":
                                n.editRevisit(u); break;
                            case "execute":
                                n.executeRevisit(u); break;
                            case "delete":
                                n.deleteRevisit(u.revisitId) } }) },
                st = function() { n.initSearchCriteria().then(function(n) { var t = { criteria: n, columns: y.columns };
                        d.exportRevisitList(t) }) },
                ht = function() { a.revisitorDic.loadActive().then(function(t) { var i = w.getPatientPermissionLevel(),
                            r;
                        i == b.PatientPermissionLevel.Department ? t = _.filter(t, function(n) { return n.department == s.department }) : i == b.PatientPermissionLevel.Personal && (t = _.filter(t, function(n) { return n.id == s.providerId }));
                        r = u.find("#groupOnlineConsultantInput").kendoDropDownList({ dataSource: t, optionLabel: "全部", dataTextField: "name", dataValueField: "id", filter: "contains", select: function(t) { n.userId = this.dataItem(t.item)[this.options.dataValueField] || -1;
                                f();
                                Ares.sensors.trackDropDownEvent("GroupRevisitList", "回访人") } }) }) },
                ct = function() { var n = $(window).height(),
                        t = n - 240,
                        i = t - 81; return Math.max(5, parseInt(i / 40)) },
                lt = function(t) { n.pageIndex = t;
                    f() },
                at = function(t) { n.pageSize = t;
                    f() },
                vt = function() { a.transactionCodeDic.load().then(function(t) { if (t) { n.transactions = t; var i = u.find("#transactions");
                            i.kendoMultiSelect({ placeholder: "请选择回访项目", dataTextField: "name", dataValueField: "id", valuePrimitive: !0, autoBind: !1, filter: "contains", dataSource: n.transactions, change: function() { var t = i.data("kendoMultiSelect");
                                    n.transactionIds = t && t.value() != "" ? t.value().join() : null;
                                    f();
                                    Ares.sensors.trackDropDownEvent("GroupRevisitList", "回访项目") } }) } }) },
                yt = function() { a.communicationMethodDic.load().then(function(t) { n.visitMethods = t; var i = u.find("#visitMethods").kendoDropDownList({ dataSource: t, optionLabel: "全部", dataTextField: "itemName", dataValueField: "itemName", select: function(t) { n.visitMethod = this.dataItem(t.item)[this.options.dataValueField] || null;
                                f();
                                Ares.sensors.trackDropDownEvent("GroupRevisitList", "沟通方式") } }) }) },
                pt = function() { a.revisitTypeDic.load().then(function(t) { n.revisitTypes = t; var i = u.find("#revisitType").kendoDropDownList({ dataSource: t, optionLabel: "全部", dataTextField: "itemName", dataValueField: "itemName", select: function(t) { n.revisitType = this.dataItem(t.item)[this.options.dataValueField] || null;
                                f();
                                Ares.sensors.trackDropDownEvent("GroupRevisitList", "回访类型") } }) }) },
                wt = function() { u.find("#timeType").kendoDropDownList({ dataSource: [{ name: "创建日期", value: 1 }, { name: "计划日期", value: 2 }, { name: "回访日期", value: 3 }], dataTextField: "name", dataValueField: "value", select: function(t) { n.timeType = this.dataItem(t.item)[this.options.dataValueField]; var i = this.dataItem(t.item)[this.options.dataTextField];
                            f();
                            Ares.sensors.trackDropDownEvent("GroupRevisitList", i) }, value: n.timeType }) },
                bt = function(t) { n.timeSpan = t;
                    f() };
            (function() { nt();
                n.transactionIds = null;
                n.revisitState = -1;
                n.selectCode = "";
                n.pageIndex = 1;
                n.initDefaultTimeSpan();
                n.pageSize = ct();
                n.searchDateChange = bt;
                n.onPageChanged = lt;
                n.onPageSizeChanged = at;
                n.providerJob = s.providerJob;
                n.toggleStateSelection = ut;
                n.isDepartmentLevel = w.getPatientPermissionLevel() == b.PatientPermissionLevel.All || w.getPatientPermissionLevel() == b.PatientPermissionLevel.Department;
                n.commands = ft;
                n.onCommandClick = ot;
                n.exportExcel = st;
                n.refreshGrid = f;
                wt();
                tt().then(function() { a.userNameDic.load().then(function() { f() }) });
                rt();
                vt();
                pt();
                yt();
                t(function() { ht() }) })() } } }]);
managementModule.directive("chargeitemImportView", ["$log", "$q", "$timeout", "aresNotification", "loginContext", "exportSvc", "$modal", function(n, t, i, r, u, f, e) { "use strict"; return { restrict: "E", replace: !0, controller: "ChargeItemImportCtrl", templateUrl: "/app/management/views/import/chargeitem-import-view.html", link: function(n) { var t = function() { var n = e.open({ animation: !0, backdrop: "static", template: "<chargeitem-import-upload-file-view><\/chargeitem-import-upload-file-view>", controller: "ChargeItemImportUploadFileCtrl", windowClass: "chargeitem-import-upload-file-dialog", size: "md", resolve: { host: function() { return { modalInstance: n } } } }) },
                i = function() { Ares.ensureNotDuplicated("exportTemplate") && f.exportChargeItemTemplate("收费项导入模板.xls") },
                r = function(n) { Ares.download(n) };
            (function() { n.openUploadDialog = t;
                n.exportTemplate = i;
                n.downloadFile = r;
                n.initData() })() } } }]);
managementModule.directive("clueImportView", ["$log", "$q", "$timeout", "aresNotification", "loginContext", "exportSvc", function(n, t, i, r, u, f) { "use strict"; return { restrict: "E", replace: !0, controller: "ClueImportCtrl", templateUrl: "/app/management/views/import/clue-import-view.html", link: function(n, t) { var e = function() { var n = t.find("#file");
                    n.click() },
                o = function(t, i) { var r = parseInt(i.loaded / i.total * 100, 10);
                    n.progress = r },
                s = function(t, f) { var o, e, s, h;
                    i();
                    n.isDisabled = !0;
                    o = f.files[0].name;
                    e = o.split(".");
                    e[e.length - 1] == "xls" || e[e.length - 1] == "xlsx" ? (n.fileName = o, s = u.apiToken, h = u.tokenType, f.url = u.apiHost + "/api/v1/document/import/clue", f.headers = f.headers || {}, f.headers.Authorization = h + " " + s, f.submit()) : (i(), r.error("文件格式不对")) },
                h = function() { i();
                    r.success("上传成功");
                    n.initData() },
                c = function() { n.isDisabled = !1;
                    n.progress = 100;
                    n.isUploadFailed = !0 },
                l = function() { i() },
                i = function() { n.isDisabled = !1;
                    n.fileName = null;
                    n.progress = 0;
                    n.isUploadFailed = !1 },
                a = function() { Ares.ensureNotDuplicated("exportTemplate") && f.exportClueTemplate("线索导入模板.xls") },
                v = function(n) { Ares.download(n) };
            (function() { n.openSelectedDialog = e;
                n.uploadProgressed = o;
                n.uploadFinished = h;
                n.uploadFailed = c;
                n.addUpload = s;
                n.cancelUpload = l;
                n.isDisabled = !1;
                n.exportTemplate = a;
                n.downloadFile = v;
                n.initData() })() } } }]);
managementModule.directive("importHomeView", ["$log", "$timeout", "$filter", "$window", "appNav", "enums", "loginContext", "permissionProvider", "systemConfigUtil", "officeOptionSvc", function(n, t, i, r, u, f, e, o, s, h) { "use strict"; return { restrict: "E", templateUrl: "/app/management/views/import/import-home-view.html", link: function(n) { var t = function() { var t = [new u.TabItem("importCenter.patient", "患者导入", "glyphicon glyphicon-import", "dataImport.patient"), new u.TabItem("importCenter.clue", "线索导入", "glyphicon glyphicon-import", "customerClueManagement.import"), new u.TabItem("importCenter.chargeitem", "收费项导入", "glyphicon glyphicon-import", "dataImport.chargeItem"), ];
                h.getOfficeOption(h.optionKeys.IsHealthBureauDataExportEnabled_Shenzhen).then(function(i) { i && (t.push(new u.TabItem("importCenter.szMonthlyReport", "卫监月报导入", "glyphicon glyphicon-import", "dataExport.healthBureauDataExport", null, null, null, null, null, { type: "monthly" })), t.push(new u.TabItem("importCenter.szAnnualReport", "卫监年报导入", "glyphicon glyphicon-import", "dataExport.healthBureauDataExport", null, null, null, null, null, { type: "annual" })));
                    n.states = t }) };
            (function() { t() })() } } }]);
managementModule.directive("patientImportView", ["$log", "$q", "$timeout", "aresNotification", "loginContext", "exportSvc", function(n, t, i, r, u, f) { "use strict"; return { restrict: "E", replace: !0, controller: "PatientImportCtrl", templateUrl: "/app/management/views/import/patient-import-view.html", link: function(n, t) { var e = function() { var n = t.find("#file");
                    n.click() },
                o = function(t, i) { var r = parseInt(i.loaded / i.total * 100, 10);
                    n.progress = r },
                s = function(t, f) { var o, e, s, h;
                    i();
                    n.isDisabled = !0;
                    o = f.files[0].name;
                    e = o.split(".");
                    e[e.length - 1] == "xls" || e[e.length - 1] == "xlsx" ? (n.fileName = o, s = u.apiToken, h = u.tokenType, f.url = u.apiHost + "/api/v1/document/import/patient", f.headers = f.headers || {}, f.headers.Authorization = h + " " + s, f.submit()) : (i(), r.error("文件格式不对")) },
                h = function() { i();
                    r.success("上传成功");
                    n.initData() },
                c = function() { n.isDisabled = !1;
                    n.progress = 100;
                    n.isUploadFailed = !0 },
                l = function() { i() },
                i = function() { n.isDisabled = !1;
                    n.fileName = null;
                    n.progress = 0;
                    n.isUploadFailed = !1 },
                a = function() { Ares.ensureNotDuplicated("exportTemplate") && f.exportPatientTemplate("患者导入模板.xls") },
                v = function(n) { Ares.download(n) };
            (function() { n.openSelectedDialog = e;
                n.uploadProgressed = o;
                n.uploadFinished = h;
                n.uploadFailed = c;
                n.addUpload = s;
                n.cancelUpload = l;
                n.isDisabled = !1;
                n.exportTemplate = a;
                n.downloadFile = v;
                n.initData() })() } } }]);
managementModule.directive("szHealthReportView", ["$log", "$q", "$timeout", "aresNotification", "loginContext", "exportSvc", function(n, t, i, r, u, f) { "use strict"; return { restrict: "E", replace: !0, controller: "SZHealthReportCtrl", templateUrl: "/app/management/views/import/sz-health-report-view.html", link: function(n, t) { var e = function() { var n = t.find("#file");
                    n.click() },
                o = function(t, i) { var r = parseInt(i.loaded / i.total * 100, 10);
                    n.progress = r },
                s = function(t, f) { var o, e, s, h; if (i(), n.isDisabled = !0, o = f.files[0].name, e = o.split("."), e[e.length - 1] == "xls" || e[e.length - 1] == "xlsx") { n.fileName = o;
                        s = u.apiToken;
                        h = u.tokenType; switch (n.type) {
                            case "monthly":
                                f.url = u.apiHost + "/api/v1/document/import/sz-monthly-report"; break;
                            case "annual":
                                f.url = u.apiHost + "/api/v1/document/import/sz-annual-report" } f.headers = f.headers || {};
                        f.headers.Authorization = h + " " + s;
                        f.submit() } else i(), r.error("文件格式不对") },
                h = function() { i();
                    r.success("上传成功");
                    n.initData() },
                c = function() { n.isDisabled = !1;
                    n.progress = 100;
                    n.isUploadFailed = !0 },
                l = function() { i() },
                i = function() { n.isDisabled = !1;
                    n.fileName = null;
                    n.progress = 0;
                    n.isUploadFailed = !1 },
                a = function() { if (Ares.ensureNotDuplicated("exportTemplate")) switch (n.type) {
                        case "monthly":
                            f.exportShenZhenMonthlyReportTemplate(); break;
                        case "annual":
                            f.exportShenZhenAnnualReportTemplate() } },
                v = function(n) { Ares.download(n) };
            (function() { n.openSelectedDialog = e;
                n.uploadProgressed = o;
                n.uploadFinished = h;
                n.uploadFailed = c;
                n.addUpload = s;
                n.cancelUpload = l;
                n.isDisabled = !1;
                n.exportTemplate = a;
                n.downloadFile = v;
                n.initData() })() } } }]);
managementModule.directive("uploadProgresseView", ["$log", function() { "use strict"; return { restrict: "E", replace: !1, templateUrl: "/app/management/views/import/upload-progresse-view.html", scope: !0, link: function() {
            (function() {})() } } }]);
managementModule.directive("invoiceHomeView", ["$log", "$timeout", "$filter", "appNav", function(n, t, i, r) { "use strict"; return { restrict: "E", templateUrl: "/app/management/views/invoice/invoice-home-view.html", scope: { officeId: "=" }, link: function(n) { var t = function() { var t = [new r.TabItem("invoiceCenter.package", "发票包管理", "icon-bag", "invoice.mgmt"), ];
                    n.states = t },
                i = function(n) { r.switchState(n, u) },
                u = function() { var t = n.officeId; return { officeId: t } };
            (function() { n.switchState = i;
                t() })() } } }]);
managementModule.directive("invoicePackageView", ["$log", "$timeout", "$filter", "$modal", "enums", "aresSlidePanel", function(n, t, i, r, u, f) { "use strict"; return { restrict: "E", replace: !0, controller: "InvoicePackageCtrl", templateUrl: "/app/management/views/invoice/invoice-package-view.html", scope: { officeId: "=" }, link: function(n, i) { var e = null,
                s = function() { var u = $(window).height() - 240,
                        n = i.find("#list-body"),
                        r;
                    n.css("height", u);
                    r = { scrollButtons: { enable: !1 }, autoHideScrollbar: !0, scrollInertia: 150, advanced: { updateOnContentResize: !0 } };
                    e == null ? (n.mCustomScrollbar(r), e = n) : e.mCustomScrollbar("update");
                    t(function() { var n = i.find(".action-icon-btn");
                        n.tooltip() }, 100) },
                h = function(n) { return (n.status === u.InvoicePackageStatus.Pending || n.status === u.InvoicePackageStatus.Cancelled) && n.usedCount === 0 },
                c = function(n) { return n.status !== u.InvoicePackageStatus.Cancelled },
                l = function(n) { return n.status === u.InvoicePackageStatus.Published },
                a = function(n) { return n.status === u.InvoicePackageStatus.Pending },
                v = function(n) { return n.status === u.InvoicePackageStatus.Published },
                y = function(n) { return n.usedCount > 0 },
                r = function(n) { var t = i.find(n.currentTarget).data("kendoTooltip");
                    t.hide() },
                p = function(t, i) { r(i);
                    o("编辑", t).then(function() { n.searchInvoicePackages() }) },
                w = function(n, t) { r(t);
                    o("查看", n) },
                b = function(t, i) { r(i);
                    n.removeUpdate(t) },
                k = function(t, i) { r(i);
                    n.pubilshUpdate(t) },
                d = function(t, i) { r(i);
                    n.revertUpdate(t) },
                g = function(n, t) { r(t);
                    nt(n) },
                o = function(t, i) { var r = f.open("<invoice-package-edit-dialog><\/invoice-package-edit-dialog>", "InvoicePackageEditDialogCtrl", { host: function() { return { title: t, invoicePackage: i } } }, n); return r.result.then(function(t) { t && n.$broadcast("customerRegistration", 1) }) },
                nt = function(t) { var i = t.invoiceNoRule,
                        r = i.prefix + Ares.getDigitsNumberStr(i.initialValue, i.seqNumberDigits),
                        u = f.open("<invoice-package-transaction-dialog><\/invoice-package-transaction-dialog>", "InvoicePackageTransactionDialogCtrl", { host: function() { return { packageId: t.id, startNumber: r } } }, n); return u.result.then(function(t) { t && n.$broadcast("customerRegistration", 1) }) },
                tt = function() { o("创建", null).then(function() { n.searchInvoicePackages() }) };
            (function() { n.initView = s;
                n.canShowTransaction = y;
                n.canRemove = h;
                n.canEdit = c;
                n.canBrowse = l;
                n.canPubilsh = a;
                n.canRevert = v;
                n.remove = b;
                n.edit = p;
                n.browse = w;
                n.pubilsh = k;
                n.revert = d;
                n.useTransaction = g;
                n.createPackage = tt })() } } }]);
managementModule.directive("medicalExamView", ["$log", "$q", "$timeout", "$filter", "$modal", "aresDialog", "moduleUtil", "$injector", "dataDicSvc", "permissionProvider", "loginContext", "reportSvc", function(n, t, i, r, u, f, e, o, s, h, c, l) { "use strict"; return { restrict: "E", replace: !0, controller: "medicalExamListCtrl", templateUrl: "/app/management/views/medicalExam/medical-exam-view.html", link: function(n, t) { var u = [{ field: "startTime", title: "预约时间" }, { field: "examTime", title: "检查时间" }, { field: "doctorName", title: "医生/咨询师" }, { field: "nurseName", title: "护士" }, { field: "examType", title: "检查类型" }, { field: "examSubType", title: "影像类型" }, { field: "equipment", title: "影像设备" }, { field: "patientName", title: "患者姓名" }, { field: "privateId", title: "病历号" }, { field: "gender", title: "性别" }, { field: "age", title: "年龄" }, { field: "mobile", title: "手机" }, { field: "notes", title: "备注" }, ],
                f = function() { var n = $(window).height() - 310;
                    t.find("#list-body").css("height", n);
                    i(function() { var n = t.find(".action-icon-btn");
                        n.tooltip() }, 100) },
                r = function() { s.doctorDic.loadActive().then(function(r) { s.consultantDic.loadActive().then(function(u) { var f = r.concat(u);
                            f.unshift({ name: "全部", id: -1 });
                            i(function() { var i = t.find("#doctorInput");
                                i.kendoDropDownList({ filter: "contains", placeholder: "请选择医生/咨询师", dataSource: f, dataTextField: "name", dataValueField: "id", select: function(t) { n.searchCriteria.doctorId = this.dataItem(t.item)[this.options.dataValueField] || null } }) }) }) }) },
                e = function() { s.nurseDic.loadActive().then(function(r) { r.unshift({ name: "全部", id: -1 });
                        i(function() { var i = t.find("#nurseInput");
                            i.kendoDropDownList({ filter: "contains", placeholder: "请选择护士", dataSource: r, dataTextField: "name", dataValueField: "id", select: function(t) { n.searchCriteria.nurseId = this.dataItem(t.item)[this.options.dataValueField] || null } }) }) }) },
                o = function() { var t = { criteria: n.searchCriteria, columns: u };
                    l.exportMedicalExamList(t) };
            (function() { n.isDoctor = c.dashboardType == "Doctor";
                n.isAssistant = c.dashboardType == "Assistant" || c.roleType == "牙科助手";
                n.initView = f;
                n.initDoctorDropdown = r;
                n.exportMedicalExamList = o;
                n.initSearchCriteriaData();
                r();
                e();
                n.searchMedicalExamPagedList() })() } } }]);
managementModule.directive("memoHomeView", ["$log", "appNav", function(n, t) { "use strict"; return { restrict: "E", templateUrl: "/app/management/views/memo/memo-home-view.html", link: function(n) { var i = function() { var i = [new t.TabItem("memo.list", "备忘查询", "", "memoManagement.record")];
                n.states = i };
            (function() { i() })() } } }]);
managementModule.directive("memoListView", ["$log", "$window", "$modal", "$timeout", "$q", "patientUtil", "kendoUtil", "enums", "dataDicSvc", "loginContext", "aresDialog", "aresNotification", "revisitSvc", "practiceSvc", "aresSlidePanel", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v) { "use strict"; return { templateUrl: "/app/management/views/memo/memo-list-view.html", controller: "MemoListCtrl", link: function(n, u) { var c, l, a, y, s, p = [{ name: "全部状态", value: null }, { name: "待处理", value: 1 }, { name: "完成", value: 2 }, { name: "作废", value: 5 }],
                d = function() { y = u.find("#providerType").kendoDropDownList({ dataSource: [{ name: "创建员工", value: 1 }, { name: "指派员工", value: 2 }, { name: "完成员工", value: 3 }], dataTextField: "name", dataValueField: "value", select: function(t) { var i = this;
                            r(function() { n.providerType = i.dataItem(t.item)[i.options.dataValueField] });
                            n.providerId = null;
                            s.value(null) } }).data("kendoDropDownList") },
                g = function() { s = u.find("#provider").kendoDropDownList({ dataSource: n.providers, filter: "contains", dataTextField: "name", dataValueField: "id", optionLabel: "全部", value: n.providerId || null, select: function(t) { var i = this.dataItem(t.item);
                            n.providerId = this.dataItem(t.item)[this.options.dataValueField] || null;
                            n.providerType == 1 && (n.providerId = i.userID) } }).data("kendoDropDownList") },
                nt = function() { l = u.find("#timeStatus").kendoDropDownList({ dataSource: [{ name: "创建时间", value: 3 }, { name: "完成时间", value: 1 }, { name: "提醒时间", value: 2 }], dataTextField: "name", dataValueField: "value", select: function(t) { var i = this;
                            r(function() { n.timeStatus = i.dataItem(t.item)[i.options.dataValueField] }) } }).data("kendoDropDownList") },
                tt = function() { c = u.find("#memoStatus").kendoDropDownList({ dataSource: p, dataTextField: "name", dataValueField: "value", select: function(t) { var i = this;
                            r(function() { n.status = i.dataItem(t.item)[i.options.dataValueField] }) } }).data("kendoDropDownList") },
                it = function() { v.getItemTypes(n.itemType).success(function(t) { var i = u.find("#subject");
                        a = i.kendoDropDownList({ dataSource: t, dataTextField: "itemName", dataValueField: "itemName", optionLabel: "全部主题", select: function(t) { n.subject = this.dataItem(t.item)[this.options.dataValueField] || null } }).data("kendoDropDownList") }) },
                rt = [{ field: "status", title: "状态", width: "60px", locked: !0, template: function(n) { var t = n.status,
                            i = _.find(p, function(n) { return n.value == t }) || ""; return '<span class="memo-status-' + t + '">' + i.name + "<\/span>" } }, { field: "subject", title: "主题", width: "190px", template: function(n) { var i = n.subject,
                            r = n.isImportant,
                            u = n.isPublic,
                            t = "<span>" + i + "<\/span>"; return r && (t += '<span class="label label-danger">重要<\/span>'), u || (t += '<span class="label label-success">私密<\/span>'), t } }, { field: "content", title: "内容", width: "250px" }, { field: "createUserName", title: "创建", width: "90px" }, { field: "assigneeProviderName", title: "指派", width: "100px" }, { field: "completeProviderName", title: "完成", width: "90px" }, { field: "recordCreatedTime", title: "创建时间", width: "110px", template: function(n) { return e.datetimeFormat(n.recordCreatedTime) } }, { field: "remindTime", title: "提醒时间", width: "120px", template: function(n) { return e.datetimeFormat(n.remindTime) } }, { field: "completeTime", title: "完成时间", width: "110px", template: function(n) { return e.datetimeFormat(n.completeTime) } }, { field: "", title: "操作", width: "140px", template: function(n) { var i = n.id,
                            r = n.status,
                            u = n.recordCreatedUser,
                            f = h.userId,
                            e = u == f,
                            t = ""; return r == 1 ? (t += '<span class="enyo-text-primary complete-button" dataId="' + i + '" style="margin-right:10px;cursor:pointer;">完成<\/span>', e && (t += '<span class="enyo-text-primary edit-button" dataId="' + i + '" status="' + r + '" style="margin-right:10px;cursor:pointer;">编辑<\/span>'), t += '<span class="enyo-text-primary delete-button" dataId="' + i + '" status="' + r + '" style="margin-right:10px;cursor:pointer;">作废<\/span>') : t += '<span class="enyo-text-primary detail-button" dataId="' + i + '" status="' + r + '" style="cursor:pointer;">查看<\/span>', t } }, ],
                w = null,
                f = function(i) { n.refreshListData(i).then(function(n) { var r, f, i;
                        w = angular.copy(rt);
                        r = u.find("#memoListGrid");
                        r.html("");
                        f = t.innerHeight - 210;
                        i = r.kendoGrid({ excel: { allPages: !0 }, dataSource: { data: n.items }, height: f, model: { id: "id" }, columns: w, sortable: !1, resizable: !0, reorderable: !0, columnMenu: !1, columnMenuInit: function(n) { n.container.find(".k-sort-asc").remove();
                                n.container.find(".k-sort-desc").remove(); var t = $(n.container).find(".k-menu-group");
                                t.find("li").each(function(n, t) { var i = $(t).text();
                                    i == " " && $(t).remove() }) } }).data("kendoGrid");
                        i.table.on("click", ".edit-button", ot);
                        i.table.on("click", ".detail-button", st);
                        i.table.on("click", ".complete-button", ht);
                        i.table.on("click", ".delete-button", ct) }) },
                ut = function(t) { n.pageIndex = t;
                    f() },
                ft = function(t) { n.pageSize = t;
                    f() },
                et = function() { nt();
                    tt();
                    it();
                    k();
                    d();
                    n.initProviders().then(function() { g() });
                    n.timeStatus = 3;
                    n.providerType = 1;
                    f(!1) },
                ot = function() { var n = $(this).attr("dataId"),
                        t = $(this).attr("status");
                    o(n, "edit") },
                st = function() { var n = $(this).attr("dataId"),
                        t = $(this).attr("status");
                    o(n, "detail") },
                ht = function() { var n = $(this).attr("dataId");
                    o(n, "complete") },
                ct = function() { var n = $(this).attr("dataId");
                    o(n, "abort") },
                lt = function() { n.status = null;
                    n.timeStatus = 3;
                    n.isImportant = !1;
                    n.subject = null;
                    n.providerType = 1;
                    n.providerId = null;
                    c.value(null);
                    l.value(3);
                    a.value(null);
                    y.value(1);
                    s.value(null);
                    f(1) },
                b = function() { f(1) },
                o = function(n, t) { var r = i.open({ animation: !0, backdrop: "static", template: "<memo-edit-view><\/memo-edit-view>", controller: "MemoEditCtrl", backdropClass: "ares-modal-backdrop", resolve: { host: function() { return { memoId: n, type: t } } } });
                    r.result.then(function(n) { n && b() }) },
                k = function() { var t = moment().format("YYYY-MM-DD"),
                        i = moment().add(1, "day").format("YYYY-MM-DD");
                    n.startTime = t;
                    n.endTime = moment(i).add(1, "day").format("YYYY-MM-DD");
                    n.timeSpan = { startDate: t, endDate: i } },
                at = function(t) { t = t || n.timeSpan;
                    n.startTime = moment(t.startDate).format("YYYY-MM-DD");
                    n.endTime = moment(t.endDate).add(1, "day").format("YYYY-MM-DD") };
            (function() { n.onPageChanged = ut;
                n.onPageSizeChanged = ft;
                n.refresh = lt;
                n.search = b;
                n.initTimeSpan = k;
                n.onDateRangeChanged = at;
                n.itemType = "备忘录主题";
                et() })() } } }]);
managementModule.directive("organizationBusinessView", ["$log", "$window", "$modal", "$timeout", "$q", "patientUtil", "kendoUtil", "enums", "dataDicSvc", "loginContext", "aresDialog", "aresNotification", "revisitSvc", "aresSlidePanel", "aresConfirmDialog", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y) { "use strict"; return { templateUrl: "/app/management/views/organization/organization-business-view.html", controller: "OrganizationBusinessCtrl", link: function(n, u) { var e, a = function() { e = u.find("#businessStatus").kendoDropDownList({ dataSource: [{ name: "全部状态", value: null }, { name: "启用", value: 0 }, { name: "停用", value: 1 }], dataTextField: "name", dataValueField: "value", select: function(t) { var i = this;
                            r(function() { n.isDisabled = i.dataItem(t.item)[i.options.dataValueField] }) } }).data("kendoDropDownList") },
                v = [{ field: "officeName", title: "诊所", width: "190px" }, { field: "departmentName", title: "科室", width: "120px" }, { field: "name", title: "职务", width: "120px" }, { field: "parentName", title: "上级", width: "120px", template: function(n) { return n.parentName ? n.parentName : "无" } }, { field: "description", title: "说明", width: "350px" }, { field: "", title: "操作", width: "130px", template: function(n) { var i = n.id,
                            t = n.isDisabled,
                            u = t ? "停用" : "启用",
                            f = t ? "config-off" : "config-on",
                            r = ""; return r += '<button style="vertical-align: text-bottom;margin-right: 10px;margin-left:2px;" class="btn icon-btn btn-light-blue btn-xs edit-button" dataId="' + i + '"><i class="iconfont icon-bianji"><\/i><\/button>', r + ('<div class="config-on-off ' + f + '" dataId="' + i + '" status="' + t + '" departmentName="' + n.name + '"><span class="config-icon">&nbsp;<\/span><span class="config-text">' + u + "<\/span><\/div>") } }, ],
                o = null,
                f = function(i) { n.refreshListData(i).then(function(n) { var i, f, r;
                        o = angular.copy(v);
                        i = u.find("#organizationBusinessGrid");
                        i.html("");
                        f = t.innerHeight - 205;
                        r = i.kendoGrid({ excel: { allPages: !0 }, dataSource: { data: n.items }, height: f, model: { id: "id" }, columns: o, sortable: !1, resizable: !0, reorderable: !0, columnMenu: !1, columnMenuInit: function(n) { n.container.find(".k-sort-asc").remove();
                                n.container.find(".k-sort-desc").remove(); var t = $(n.container).find(".k-menu-group");
                                t.find("li").each(function(n, t) { var i = $(t).text();
                                    i == " " && $(t).remove() }) } }).data("kendoGrid");
                        r.table.on("click", ".edit-button", k);
                        r.table.on("click", ".config-on-off", d) }) },
                p = function(t) { n.pageIndex = t;
                    f() },
                w = function(t) { n.pageSize = t;
                    f() },
                b = function() { a();
                    f() },
                k = function() { var n = $(this).attr("dataId");
                    c(n) },
                d = function() { var n = $(this).attr("dataId"),
                        t = $(this).attr("status"),
                        i = $(this).attr("departmentName");
                    t == "true" ? g(n) : nt(n, i) },
                g = function(t) { n.enableJobTitle(t).then(function(n) { n ? (l.success("操作成功！"), f()) : l.error("操作失败！") }) },
                nt = function(t, i) { n.canDisableJobTitle(t).then(function(n) { n ? s(t) : y.warn({ message: "当前职务 <span class='enyo-text-primary'>" + i + "<\/span> 存在下级职务是否一起停用？", onConfirm: function() { s(t) } }) }) },
                s = function(t) { n.disableJobTitle(t).then(function(n) { n ? (l.success("操作成功！"), f()) : l.error("操作失败！") }) },
                tt = function() { n.isDisabled = null;
                    e.value(null);
                    f(1) },
                h = function() { f(1) },
                c = function(n) { var t = i.open({ animation: !0, backdrop: "static", template: "<organization-business-edit-view><\/organization-business-edit-view>", controller: "OrganizationBusinessEditCtrl", backdropClass: "ares-modal-backdrop", resolve: { host: function() { return { businessId: n } } } });
                    t.result.then(function(n) { n && h() }) },
                it = function() { c() };
            (function() { n.onPageChanged = p;
                n.onPageSizeChanged = w;
                n.refresh = tt;
                n.search = h;
                n.businessEditDialog = it;
                b() })() } } }]);
managementModule.directive("organizationDepartmentView", ["$log", "$window", "$modal", "$timeout", "$q", "patientUtil", "kendoUtil", "enums", "dataDicSvc", "loginContext", "aresDialog", "aresNotification", "revisitSvc", "aresSlidePanel", function(n, t, i, r, u, f, e, o, s, h, c, l) { "use strict"; return { templateUrl: "/app/management/views/organization/organization-department-view.html", controller: "OrganizationDepartmentCtrl", link: function(n, u) { var e, o, a = [{ name: "全部状态", value: -1 }, { name: "行政", value: 1 }, { name: "医疗", value: 2 }],
                v = function() { e = u.find("#departmentStatus").kendoDropDownList({ dataSource: [{ name: "全部状态", value: null }, { name: "启用", value: 0 }, { name: "停用", value: 1 }], dataTextField: "name", dataValueField: "value", select: function(t) { var i = this;
                            r(function() { n.isDisabled = i.dataItem(t.item)[i.options.dataValueField] }) } }).data("kendoDropDownList") },
                y = function() { o = u.find("#departmentType").kendoDropDownList({ dataSource: a, dataTextField: "name", dataValueField: "value", select: function(t) { var i = this;
                            r(function() { n.departmentTypes = i.dataItem(t.item)[i.options.dataValueField] }) } }).data("kendoDropDownList") },
                p = [{ field: "officeName", title: "诊所", width: "190px" }, { field: "name", title: "科室", width: "120px" }, { field: "departmentType", title: "类型", width: "120px", template: function(n) { var i = n.departmentType,
                            t = ""; return i == 1 ? t = "行政" : i == 2 && (t = "医疗"), t } }, { field: "parentName", title: "上级", width: "120px", template: function(n) { return n.parentName ? n.parentName : "无" } }, { field: "location", title: "位置", width: "200px" }, { field: "description", title: "介绍", width: "350px" }, { field: "", title: "操作", width: "130px", template: function(n) { var i = n.id,
                            t = n.isDisabled,
                            u = t ? "停用" : "启用",
                            f = t ? "config-off" : "config-on",
                            r = ""; return r += '<button style="vertical-align: text-bottom;margin-right: 10px;margin-left:2px;" class="btn icon-btn btn-light-blue btn-xs edit-button" dataId="' + i + '"><i class="iconfont icon-bianji"><\/i><\/button>', r + ('<div class="config-on-off ' + f + '" dataId="' + i + '" status="' + t + '"><span class="config-icon">&nbsp;<\/span><span class="config-text">' + u + "<\/span><\/div>") } }, ],
                s = null,
                f = function(i) { n.refreshListData(i).then(function(n) { var i, f, r;
                        s = angular.copy(p);
                        i = u.find("#organizationDepartmentGrid");
                        i.html("");
                        f = t.innerHeight - 205;
                        r = i.kendoGrid({ excel: { allPages: !0 }, dataSource: { data: n.items }, height: f, model: { id: "id" }, columns: s, sortable: !1, resizable: !0, reorderable: !0, columnMenu: !1, columnMenuInit: function(n) { n.container.find(".k-sort-asc").remove();
                                n.container.find(".k-sort-desc").remove(); var t = $(n.container).find(".k-menu-group");
                                t.find("li").each(function(n, t) { var i = $(t).text();
                                    i == " " && $(t).remove() }) } }).data("kendoGrid");
                        r.table.on("click", ".edit-button", d);
                        r.table.on("click", ".config-on-off", g) }) },
                w = function(t) { n.pageIndex = t;
                    f() },
                b = function(t) { n.pageSize = t;
                    f() },
                k = function() { v();
                    y();
                    f() },
                d = function() { var n = $(this).attr("dataId");
                    c(n) },
                g = function() { var n = $(this).attr("dataId"),
                        t = $(this).attr("status");
                    t == "true" ? nt(n) : tt(n) },
                nt = function(t) { n.enableDepartment(t).then(function(n) { n ? (l.success("操作成功！"), f()) : l.error("操作失败！") }) },
                tt = function(t) { n.disableDepartment(t).then(function(n) { n ? (l.success("操作成功！"), f()) : l.error("操作失败！") }) },
                it = function() { n.isDisabled = null;
                    n.departmentTypes = -1;
                    e.value(null);
                    o.value(-1);
                    f(1) },
                h = function() { f(1) },
                c = function(n) { var t = i.open({ animation: !0, backdrop: "static", template: "<organization-department-edit-view><\/organization-department-edit-view>", controller: "OrganizationDepartmentEditCtrl", backdropClass: "ares-modal-backdrop", resolve: { host: function() { return { departmentId: n } } } });
                    t.result.then(function(n) { n && h() }) },
                rt = function() { c() };
            (function() { n.onPageChanged = w;
                n.onPageSizeChanged = b;
                n.refresh = it;
                n.search = h;
                n.departmentEditDialog = rt;
                k() })() } } }]);
managementModule.directive("organizationHomeView", ["$log", "appNav", function(n, t) { "use strict"; return { restrict: "E", templateUrl: "/app/management/views/organization/organization-home-view.html", link: function(n) { var i = function() { var i = [new t.TabItem("organizationCenter.orgmanagement", "组织管理", "", ""), new t.TabItem("organizationCenter.department", "科室管理", "", ""), new t.TabItem("organizationCenter.business", "职务管理", "", "")];
                n.states = i };
            (function() { i() })() } } }]);
managementModule.directive("organizationOrgmanagementView", ["$log", "$window", "$modal", "$timeout", "$q", "dataDicSvc", "loginContext", "orgmanagementSvc", "aresDialog", "officeSvc", function(n, t, i, r, u, f, e, o, s, h) { "use strict"; return { templateUrl: "/app/management/views/organization/organization-orgmanagement-view.html", controller: "OrganizationOrgmanagementCtrl", link: function(n, t) { var y, f, p = 1,
                c, w = function(t) { var i = this.dataItem(t.node),
                        r = i.id;
                    n.selectedOfficeId = r;
                    c = [];
                    n.selectedOffice = !0;
                    n.dCatalogData = !0;
                    v();
                    d() },
                b = function() { var i = new kendo.data.HierarchicalDataSource({ transport: { read: function(t) { if (!t.data.id) { t.success([{ id: e.officeId, hasChildren: !0, name: n.officeInfo.name, isLeaf: !1 }]); return } h.getOfficeNodesByParent(t.data.id).success(function(n) { t.success(n) }).error(function(n) { t.error(n) }) } }, schema: { model: { id: "id", hasChildren: "hasChildren" } } });
                    y = t.find("#ortTreeview").kendoTreeView({ dataSource: i, dataTextField: "name", select: w }).data("kendoTreeView") },
                k = function(t) { var f = t,
                        h = "",
                        s, r, i, e, a; if (t && (s = t.split(":"), f = s[1], h = s[3]), r = u.defer(), i = { officeId: n.selectedOfficeId, parentId: f }, c.length > 0)
                        if (e = _.find(c, function(n) { return n.realId == f && n.nodeType == h }), e) { var v = e.hasChildren,
                                o = e.nodeType,
                                y = e.isLeaf;
                            v && (y ? (i.parentType = o, o == 2 && (i.departmentId = 0), l(i).then(function(n) { i.departmentId = f;
                                i.parentType = o + 1;
                                i.parentId = 0;
                                o == 2 && (i.parentId = f, i.departmentId = 0);
                                l(i).then(function(t) { var i = n.concat(t);
                                    r.resolve(i) }) })) : (i.parentType = o, l(i).then(function(n) { r.resolve(n) }))) } else a = [], r.resolve(a);
                    else i.parentType = p, l(i).then(function(n) { r.resolve(n) }); return r.promise },
                l = function(n) { var t = u.defer(); return o.listDepartmentNode(n).success(function(n) { var i = [];
                        _.each(n, function(n) { var f = n.isLeaf,
                                r = n.nodeType,
                                t = "",
                                u;
                            f && (n.hasChildren = !0);
                            r == 2 && (t = "iconfont icon-jiahao");
                            r == 3 && (t = "iconfont icon-shanchu");
                            u = { id: "id:" + n.id + ":t:" + n.nodeType, realId: n.id, hasChildren: n.hasChildren, isLeaf: n.isLeaf, name: n.name, nodeType: n.nodeType, parentId: n.parentId, icon: t };
                            i.push(u) });
                        t.resolve(i) }), t.promise },
                d = function() { var i = t.find("#departmentTreeview"),
                        u;
                    i.html("");
                    kendo.destroy(i);
                    u = new kendo.data.HierarchicalDataSource({ transport: { read: function(n) { var t = n.data.id;
                                k(t).then(function(t) { c = c.concat(t);
                                    n.success(t) }) } }, schema: { model: { hasChildren: "hasChildren" } } });
                    f = i.kendoTreeView({ dataSource: u, dataTextField: "name", template: '<div class="tree-item-name clearfix">#= item.name # <span class="#= item.icon #"><\/span><\/div>' }).data("kendoTreeView");
                    $(document).on("click", ".iconfont.icon-jiahao", function(t) { t.preventDefault();
                        t.stopPropagation(); var i = $(this),
                            u = "add";
                        n.operTypeNum = 1;
                        r(function() { a(i, u) }) });
                    $(document).on("click", ".iconfont.icon-shanchu", function(t) { t.preventDefault();
                        t.stopPropagation(); var i = $(this),
                            u = "delete";
                        n.operTypeNum = 1;
                        r(function() { a(i, u) }) }) },
                a = function(t, i) { var e = t.closest(".k-item"),
                        r = f.dataItem(e),
                        u;
                    (n.operTypeNum++, n.operTypeNum > 2) || (u = r.realId ? r.realId : r.id, i == "add" ? (f.expand("#departmentTreeview_tv_active.k-item"), g(u)) : i == "delete" && tt(u)) },
                g = function(t) { var r = i.open({ animation: !0, backdrop: "static", template: "<organization-provider-job-title-edit-view><\/organization-provider-job-title-edit-view>", controller: "OrganizationProviderJobTitleEditCtrl", backdropClass: "ares-modal-backdrop", resolve: { host: function() { return { officeId: n.selectedOfficeId, jobTitleId: t } } } });
                    r.result.then(function(n) { n && nt(n) }) },
                nt = function(n) { var t = f.select();
                    n && (n.icon = "iconfont icon-shanchu", n.hasChildren = !1);
                    f.append(n, t) },
                tt = function(t) { s.confirm("提示", "确认删除该员工吗？").then(function() { n.deleteProvider(t).then(function() { var n = f.select();
                            f.remove(n) }) }) },
                it = function(i) { if (i != "") { var r = { officeId: n.selectedOfficeId, parentType: 1, parentId: 0, providerName: i };
                        n.isSearch = !0;
                        o.queryDepartmentNode(r).success(function(n) { var u = new kendo.data.HierarchicalDataSource({ data: n, schema: { model: { children: "childrens", expanded: !0, hasChildren: "childrens" } } }),
                                r = t.find("#departmentTreeviewSearch"),
                                i;
                            r.html("");
                            kendo.destroy(r);
                            i = r.kendoTreeView({ dataSource: u, dataTextField: "name" }).data("kendoTreeView");
                            i.expand(".k-item");
                            i.expand("li.k-last");
                            i.expand(i.element.find(".k-item")) }) } else n.isSearch = !1 },
                v = function() { n.providerName = "";
                    n.isSearch = !1 };
            (function() { n.search = it;
                n.adminOffice = h.adminOffice;
                n.clearSearch = v;
                n.getOffice().then(function() { b() }) })() } } }]);
managementModule.directive("orgchainBaseDataView", ["$log", "$timeout", "$modal", "enums", "practiceSvc", "officeSvc", "loginContext", "dataDicSvc", "aresDialog", "moduleOptionProvider", "officeOptionSvc", function(n, t, i, r, u, f, e, o, s, h, c) { "use strict"; return { replace: !0, templateUrl: "/app/management/views/orgchain/orgchain-base-data-view.html", link: function(n) { var t = r.BaseDataCategory,
                u, p, l = [{ category: t.ChargeItem, title: "收费", description: "收费类别，收费项目，收费项目划扣步骤，收费组合，收费类型，支付方式，划扣方案，诊断项目，收费项目自由项配置，治疗计划项目配置" }, { category: t.Appointment, title: "预约挂号", description: "预约大类，预约项目，咨询项目，挂号类型" }, { category: t.EMR, title: "电子病历", description: "病历基础配置，病历模板，词条配置" }, { category: t.PatientInfo, title: "患者信息", description: "患者类型，国籍，过敏源，用药史，既往史，关系类别，手机号码属性，电话号码属性" }];
            h.isReferralEnabled() && l.push({ category: t.Referral, title: "推荐管理", description: "患者推荐激励配置，患者推荐激励规则" });
            h.isNewMedicalExamEnabled() && l.push({ category: t.EHR, title: "检查", description: "检查大类，检查项目，检查项目费用" }); var y = function() { o.officeBaseDataOptionDic.load().then(function(t) { l.forEach(function(i) { var r = t.find(function(n) { return n.category === i.category });
                            r && (i.isParentEnabled = r.isParentEnabled, i.isPublic = r.isPublic, i.isParentPublic = r.isParentPublic, i.isParentAdminOffice = r.isParentAdminOffice, i.canUseParent = !i.isParentAdminOffice && i.category > 0 && n.isRegularChainOffice, i.canBePublic = i.category > 0) });
                        n.options = l });
                    n.isGroup = e.officeType === 1 },
                w = function() { f.get(e.officeId).success(function(t) { n.isRegularChainOffice = t.bizType == r.BizType.RegularChain;
                        y() }) },
                b = function(n) { n.canUseParent && (n.isParentEnabled || n.isParentPublic ? !n.isParentEnabled && n.isParentPublic ? s.confirm("提示", "同步并切换至上级" + n.title + "基础数据，是否继续？").then(function() { a(n) }) : s.confirm("提示", "切换至本地" + n.title + "基础数据，是否继续？").then(function() { a(n) }) : s.confirm("提示", "上级" + n.title + "基础数据没有共享，是否继续切换？").then(function() { a(n) })) },
                a = function(n) { n.isParentEnabled = !n.isParentEnabled;
                    f.updateOfficeBaseDataOption(n).success(function() { o.officeBaseDataOptionDic.clearCache();
                        k(n);
                        s.info("提示", n.title + "基础数据切换成功！") }).error(function() { s.error("错误", n.title + "基础数据切换失败！") }) },
                k = function(t) { n.options = [];
                    y();
                    d(t) },
                d = function(n) { n.category == t.ChargeItem ? (o.chargeItemDic.clearCache(), o.chargeCategoryDic.clearCache(), o.chargeSuperCategoryDic.clearCache(), o.payTypeDic.clearCache(), o.systemsettingDic.clearCache(), o.paymentTypeDic.clearCache(), g(n)) : n.category == t.PatientInfo ? (o.medicineNowDic.clearCache(), o.diseaseDic.clearCache(), o.medicineDic.clearCache()) : n.category == t.Appointment && (o.transactionCodeDic.clearCache(), o.consultItemDic.clearCache()) },
                g = function(n) { n.category == t.ChargeItem && (c.clearOptionCache(c.optionKeys.PaymentTypeUpgradeStatus), c.clearOptionCache(c.optionKeys.IsNewPaymentTypeEnabled)) },
                nt = function(n) { n.canBePublic && (n.isPublic = !n.isPublic, f.updateOfficeBaseDataOption(n).success(function() { o.officeBaseDataOptionDic.clearCache();
                        n.isPublic && s.info("提示", n.title + "基础数据已经共享，请向下分发！") }).error(function() { s.error("错误", n.title + "更新失败") })) },
                tt = function(n) { n.category < 0 || !n.isPublic || f.getDistributionList(n.category).success(function(t) { t.length <= 0 ? s.info("基础数据分发", "没有要分发的下级！") : s.confirm("分发", "有" + t.length + "个诊所需要分发，确定分发吗？").then(function() { t.forEach(function(n) { n.state = "unsync" });
                            t.allDown = !1;
                            u = t;
                            v(n.category);
                            it(n.category) }) }).error(function() { s.warn("出错啦", "数据分发发生异常") }) },
                v = function(n) { var t = _.find(u, function(n) { return n.state == "unsync" });
                    t ? (t.state = "synchronizing", f.syncBaseData(t.childOfficeId, t.parentOfficeId, n).success(function() { t.state = "completed";
                        v(n) }).error(function() { t.state = "error";
                        v(n) })) : u.allDone = !0 },
                it = function(n) { p = i.open({ animation: !0, backdrop: "static", template: "<orgchain-base-data-sync-info-dialog-view><\/orgchain-base-data-sync-info-dialog-view>", controller: "OrgchainBaseDataSyncInfoDialogCtrl", windowClass: "width-400-dialog", size: "md", resolve: { host: function() { return { categoryName: rt(n), distributionList: u } } } }) },
                rt = function(n) { return n == r.BaseDataCategory.ChargeItem ? "收费" : n == r.BaseDataCategory.Inventory ? "库存" : n == r.BaseDataCategory.Appointment ? "预约" : n == r.BaseDataCategory.Membership ? "会员" : n == r.BaseDataCategory.EMR ? "电子病历" : n == r.BaseDataCategory.Patient ? "患者" : "" };
            (function() { w();
                n.options = [];
                n.isAres3 = window.Ares3;
                n.onIsParentEnabledClicked = b;
                n.onIsPublicClicked = nt;
                n.onDistributionClicked = tt })() } } }]);
managementModule.directive("orgchainBusinessDataView", ["dataDicSvc", function(n) { "use strict"; return { replace: !0, templateUrl: "/app/management/views/orgchain/orgchain-business-data-view.html", link: function(t) { var i = function() { n.officeInfoDic.load().then(function(n) { t.office = n }) };
            (function() { t.isAres3 = window.Ares3;
                i() })() } } }]);
managementModule.directive("orgchainHomeView", ["$log", "$timeout", "$filter", "$window", "appNav", "enums", "permissionProvider", "practiceSvc", function(n, t, i, r, u) { "use strict"; return { restrict: "E", templateUrl: "/app/management/views/orgchain/orgchain-home-view.html", link: function(n) { var t = function() { var t = [new u.TabItem("orgchainCenter.baseData", "配置分发", "icon-notebook", null), new u.TabItem("orgchainCenter.bizData", "数据共享", "icon-notebook", null)];
                n.states = t };
            (function() { t() })() } } }]);
managementModule.directive("dentureProductsEditView", ["$log", "$timeout", function(n, t) { "use strict"; return { replace: !0, restrict: "E", templateUrl: "/app/management/views/outprocess/denture-products-edit-view.html", link: function(n, i) { var r, u = function() { r = Ares.validateForm(i.find("#dentureProductsForm"), { dentureProduct: { required: !0 } }, { dentureProduct: { required: "义齿产品不能为空" } }) },
                f = function() { i.find("#dentureProductsForm").valid() && n.saveDenture() };
            (function() { u();
                n.validAndSave = f;
                n.$watch("dentureProductsForm", function() { r && Ares.clearError(i.find("#dentureProductsForm")) });
                t(function() { Ares.centerModal(i.closest(".modal-dialog")) }, 5) })() } } }]);
managementModule.directive("dentureProductsView", ["$log", "$timeout", "$filter", "$window", "appNav", "dashboardSvc", "enums", "permissionProvider", "patientSvc", function(n, t, i, r) { "use strict"; return { restrict: "E", replace: !0, controller: "PentureProductsCtrl", templateUrl: "/app/management/views/outprocess/denture-products-view.html", scope: { officeId: "=" }, link: function(n, t) { var u = Ares.kendoGridUtil(r, n),
                i = !1,
                f = function() { if (n.dentureProductsList) { i = !0; var r = t.find("#dentureProductsList");
                        r.kendoGrid({ dataSource: { data: n.dentureProductsList }, scrollable: !1, sortable: !0, selectable: "single", model: { id: "id" }, columns: [{ field: "index", title: "序号", width: "60px" }, { field: "productCatagory", title: "义齿类别", width: "60px" }, { field: "dentureType", title: "二级类别", width: "60px" }, { field: "dentureProduct", title: "产品名称", width: "120px" }, { field: "material", title: "产品材料", width: "100px" }, { field: "repairType", title: "修复形式", width: "100px" }, { field: "processMethod", title: "加工方式", width: "100px" }, { field: "stentMaterial", title: "支架材料", width: "100px" }, { field: "baseMaterial", title: "基托材料", width: "100px" }, { template: u.commandTemplate, title: "", width: "150px" }] }) } },
                e = function(t) { return _.find(n.dentureProductsList, function(n) { return n.id == t }) },
                o = [{ text: "修改", action: "update", icon: "glyphicon-pencil" }, { text: "删除", action: "delete", icon: "glyphicon-remove" }, ],
                s = function(t, i, r) { var u = e(r); switch (i) {
                        case "update":
                            n.updateFactory(u); break;
                        case "delete":
                            n.deleteFactory(u);
                            refreshGrid() } },
                h = function() { var t = $("#dentureProductsList"),
                        i = t.data("kendoGrid");
                    i.dataSource.data(n.dentureProductsList) },
                c = function() { var n = t.find("#dentureProductsList").data("kendoGrid");
                    n && n.saveAsExcel() };
            (function() { n.commands = o;
                n.onCommandClick = s;
                n.exportExcel = c;
                n.$watch("dentureProductsList", function() { i ? h() : f() }) })() } } }]);
managementModule.directive("outprocessFactoryView", ["$log", "$timeout", "$filter", "$window", "appNav", "dashboardSvc", "enums", "permissionProvider", "patientSvc", function(n, t, i, r) { "use strict"; return { restrict: "E", replace: !0, controller: "OutprocessFactoryCtrl", templateUrl: "/app/management/views/outprocess/outprocess-factory-view.html", scope: { officeId: "=" }, link: function(n, t) { var u = Ares.kendoGridUtil(r, n),
                i = !1,
                f = function() { if (n.outprocessFactoryList) { i = !0; var r = t.find("#outprocessFactoryList");
                        r.kendoGrid({ dataSource: { data: n.outprocessFactoryList }, scrollable: !1, sortable: !0, selectable: "single", model: { id: "id" }, columns: [{ field: "index", title: "序号", width: "60px" }, { field: "factoryName", title: "加工厂名称", width: "60px" }, { field: "principalName", title: "负责人姓名", width: "120px" }, { field: "principalPhone", title: "负责人电话", width: "70px" }, { field: "salesMan", title: "业务员姓名", width: "80px" }, { field: "salesManPhone", title: "业务员电话", width: "60px" }, { field: "email", title: "邮箱", width: "120px" }, { field: "weiXin", title: "微信", width: "120px" }, { template: u.commandTemplate, title: "", width: "150px" }] }) } },
                e = function(t) { return _.find(n.outprocessFactoryList, function(n) { return n.id == t }) },
                o = [{ text: "修改", action: "update", icon: "glyphicon-pencil" }, { text: "删除", action: "delete", icon: "glyphicon-remove" }, ],
                s = function(t, i, r) { var u = e(r); switch (i) {
                        case "update":
                            n.updateFactory(u); break;
                        case "delete":
                            n.deleteFactory(u);
                            refreshGrid() } },
                h = function() { var t = $("#outprocessFactoryList"),
                        i = t.data("kendoGrid");
                    i.dataSource.data(n.outprocessFactoryList) },
                c = function() { var n = t.find("#outprocessFactoryList").data("kendoGrid");
                    n && n.saveAsExcel() };
            (function() { n.commands = o;
                n.onCommandClick = s;
                n.exportExcel = c;
                n.$watch("outprocessFactoryList", function() { i ? h() : f() }) })() } } }]);
managementModule.directive("outprocessHomeView", ["$log", "$timeout", "$filter", "$window", "appNav", "enums", "permissionProvider", "practiceSvc", function(n, t, i, r, u, f, e, o) { "use strict"; return { restrict: "E", templateUrl: "/app/management/views/outprocess/outprocess-home-view.html", link: function(n) { var t = function() { var t = !1;
                o.getSystemConfigByName("AllowConnectFactory").success(function(i) { i.configValue == "true" && (t = !0); var r = [new u.TabItem("outprocessCenter.outprocess", "技加工管理", "icon-notebook", "managementCenter.outprocess"), ];
                    t && (r.push(new u.TabItem("outprocessCenter.factory", "加工厂信息配置", "icon-home", "managementCenter.outprocess")), r.push(new u.TabItem("outprocessCenter.dentureProducts", "义齿产品配置", "glyphicon glyphicon-th", "managementCenter.outprocess")));
                    n.states = r }) };
            (function() { t() })() } } }]);
managementModule.directive("outprocessorderBorwserView", ["$q", "$log", "$timeout", "$filter", "$window", "appNav", "toothUtil", "enums", "permissionProvider", "loginContext", "dataDicSvc", "patientSvc", "printUtil", function(n, t, i, r, u, f, e, o, s, h, c, l) { "use strict"; return { restrict: "E", replace: !0, controller: "OutprocessorderBorwserCtrl", templateUrl: "/app/management/views/outprocess/outprocessorder-borwser-view.html", scope: { officeId: "=" }, link: function(n, t) { var o = Ares.kendoGridUtil(u, n),
                i = !1;
            u.OutProcessPatientCtrl_goToPatient = function(n) { var t = $(n).closest("tr"),
                    i = $("#outprocessorderList").data("kendoGrid"),
                    r = i.dataItem(t); return f.goToPatient(r.patientId), !1 };
            $(".isHideData").hide();
            $("#daysBeforeTodayInput").change(function() { $("#daysBeforeTodayInput").val() == "自定义" ? $(".isHideData").show() : $(".isHideData").hide() }); var h = function() { var r = s.isAllowed("patientOutProcess.viewPrice"),
                        u;
                    n.outprocessorderList && (i = !0, u = t.find("#outprocessorderList"), u.kendoGrid({ dataSource: { data: n.outprocessorderList, aggregate: [{ field: "factoryPrice", aggregate: "sum" }, { field: "customerPrice", aggregate: "sum" }] }, excel: { fileName: "加工单.xlsx" }, detailInit: b, scrollable: !1, sortable: !0, selectable: "single", model: { id: "id" }, columns: [{ field: "patientName", title: "患者姓名", width: "60px", footerTemplate: "总计", template: kendo.template($("#outprocesstemplate").html()) }, { field: "privateId", title: "病历号", width: "60px" }, { field: "startTime", title: "就诊时间", width: "120px" }, { field: "doctorName", title: "医生", width: "70px" }, { field: "supplyName", title: "加工单位", width: "80px" }, { field: "count", title: "数量", width: "50px" }, { hidden: !r, field: "factoryPrice", title: "加工费", width: "50px", format: "{0:n}", aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }, { hidden: !r, field: "customerPrice", title: "患者收费", width: "50px", format: "{0:n}", aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }, { field: "sendDate", title: "送件时间", width: "120px" }, { field: "backDate", title: "收件时间", width: "120px" }, { field: "status", title: "状态", width: "80px" }, { field: "notes", title: "备注", width: "100px" }, { template: o.commandTemplate, title: "", width: "50px" }] }));
                    n.initGridClone() },
                c = [{ text: "查看技加工", action: "goToOutprocess", icon: "glyphicon-log-in" }, ],
                r = function(t) { return _.find(n.outprocessorderList, function(n) { return n.id == t }) },
                a = function(n) { f.goToOutprocess(n) },
                v = function(t, i, u) { n.$apply(function() { var n = r(u); switch (i) {
                            case "goToOutprocess":
                                a(n.patientId) } }) },
                y = function() { var t = $("#outprocessorderList"),
                        i = t.data("kendoGrid");
                    i.dataSource.data(n.outprocessorderList);
                    n.initGridClone() },
                p = function(n) { angular.forEach(n, function(n) { w(n);
                        n.count = n.count == null ? "" : n.count }) },
                w = function(n) { var t = [
                            [],
                            [],
                            [],
                            []
                        ],
                        i = n.fdiToothCodes.length > 0 ? n.fdiToothCodes.split(",") : null;
                    i && i.length > 0 && angular.forEach(i.sort(), function(n) { var i = e.getTooth(n),
                            r = i.getQuadrant(),
                            u = i.getQuadrantCode();
                        t[r - 1].push(u) });
                    n.topLeft = t[0].reverse().join("");
                    n.topRight = t[1].join("");
                    n.bottomRight = t[2].join("");
                    n.bottomLeft = t[3].reverse().join("") },
                b = function(n) { l.getFullOutProcessOrder(n.data.id).success(function(t) { if (t && t.orderDetailList.length > 0) { var i = t.orderDetailList;
                            p(i) } $("<div/>").appendTo(n.detailCell).kendoGrid({ dataSource: i, rowTemplate: kendo.template($("#rowTemplate").html()), scrollable: !1, sortable: !0, columns: [{ field: "tooth", title: "牙位图", width: "150px" }, { field: "itemName", title: "技加工项目" }, { field: "colorCode", title: "色号" }, { field: "count", title: "数量" }, ] }) }) },
                k = function() { var n = t.find("#outprocessorderList").data("kendoGrid");
                    n && n.saveAsExcel() },
                d = function() { var t, i;
                    n.outprocessorderList.length > 0 && (t = [{ field: "patientName", title: "患者姓名" }, { field: "privateId", title: "病历号" }, { field: "apptTime", title: "就诊时间" }, { field: "doctorName", title: "医生" }, { field: "supplyName", title: "加工单位" }, { field: "fDIToothCodes", title: "牙位" }, { field: "itemName", title: "加工项目" }, { field: "colorCode", title: "色号" }, { field: "sendDate", title: "送件时间" }, { field: "backDate", title: "取件时间" }, { field: "status", title: "状态" }, { field: "notes", title: "备注" }, ], n.outProcessOrderCriteria.doctorId = n.outProcessOrderCriteria.doctorId && n.outProcessOrderCriteria.doctorId <= 0 ? -1 : -1, n.outProcessOrderCriteria.supplyName || (n.outProcessOrderCriteria.supplyName = -1), n.outProcessOrderCriteria.stateName || (n.outProcessOrderCriteria.stateName = -1), n.outProcessOrderCriteria.isBySendDate = n.isBySendDate, i = { criteria: n.outProcessOrderCriteria, columns: t }, l.exportOutProcessOrderDetail(i)) },
                g = function() { n.outProcessOrderCriteria.dateType == "自定义" && $(".isHideData").show() },
                nt = function(n, t) { var i = n ? "送件时间" : "收件时间";
                    t && (i = i + "选择");
                    Ares.sensors.trackDropDownEvent("OutprocessorderBorwser", i) };
            (function() { g();
                n.handleKendoDropDownSelect = nt;
                n.exportExcel = k;
                n.exportDetail = d;
                n.commands = c;
                n.onCommandClick = v;
                n.findPat = r;
                n.$watch("outprocessorderList", function() { i ? y() : h() });
                n.$on("$destroy", function() { delete u.UnchargedPatientCtrl_goToPatient }) })() } } }]);
var management;
(function() { "use strict"; var n = function() {
        function n() { this.restrict = "E";
            this.templateUrl = "/app/management/views/patient-video/patient-video-view.html";
            this.replace = !0;
            this.controller = "PatientVideoCtrl";
            this.link = function() {
                (function() {})() } } return n.$inject = [], n }();
    managementModule.directive("patientVideoView", Ares.tsDirective(n)) })(management || (management = {}));
var management;
(function() { "use strict"; var n = function() {
        function n(n, t, i) { this.$scope = n;
            this.$modal = t;
            this.ehrSvc = i;
            this.$scope.patientVideoList = [];
            this.fetchVideoList();
            Ares.sensors.track("$pageview", { $url_path: "/management-center/patient-video", $title: "医患沟通视频" }) } return n.prototype.fetchVideoList = function() { var n = this;
            this.ehrSvc.getPatientVideoList().then(function(t) { t.data && (n.$scope.patientVideoList = t.data) }) }, n.prototype.handlePlay = function(n, t) { var i = this,
                r = this.$modal.open({ animation: !0, backdrop: "static", template: "<patient-video-play-dialog-view><\/patient-video-play-dialog-view>", controller: "PatientVideoPlayDialogCtrl", windowClass: "patient-video-play-dialog-modal", resolve: { host: function() { return { video: n, index: t, videoList: i.$scope.patientVideoList, loop: !0 } } } });
            Ares.sensors.track("$webClick", { $element_content: "医患视频点击" }) }, n.$inject = ["$scope", "$modal", "ehrSvc"], n }();
    managementModule.controller("PatientVideoCtrl", Ares.tsController(n)) })(management || (management = {}));
managementModule.directive("tagCenterHomeView", ["$log", "$timeout", "$filter", "$window", "appNav", "enums", "permissionProvider", function(n, t, i, r, u) { "use strict"; return { restrict: "E", templateUrl: "/app/management/views/patienttag/tag-center-home-view.html", link: function(n) { var t = function() { var t = [new u.TabItem("tagCenter.patienttag", "标签管理", "icon-notebook", "managementCenter.tagCenter"), ];
                n.states = t };
            (function() { t() })() } } }]);
managementModule.directive("personalChargeDetailView", ["$log", "$timeout", "appNav", "dataDicSvc", "practiceSvc", "reportSvc", "patientSvc", "$q", "permissionProvider", function(n, t, i) { return { restrict: "E", templateUrl: "/app/management/views/personal-performance/personal-charge-detail-view.html", controller: "PersonalChargeDetailCtrl", link: function(n, r) { var f, u, e = function() { var e, t, i; if (n.pageData) { for (e = $(window).height() - 170, t = [{ field: "privateId", title: "病历号", width: "100px", footerTemplate: "总计" }, { field: "patientName", title: "患者姓名", width: "100px" }, { field: "mobile", title: "患者手机", width: "110px", hidden: !1 }, { field: "sourceType", title: "患者来源", width: "80px" }, { field: "status", title: "收费状态", width: "80px" }, { field: "payTimeStr", title: "收费时间", width: "180px" }, { field: "doctorName", title: "医生", width: "70px" }, { field: "nurseName", title: "护士", width: "70px" }, { field: "payee", title: "收款人", width: "150px" }, { field: "originalPrice", title: "原价", format: "{0:n}", width: "150px" }, { field: "totalDisCountPrice", title: "折扣金额", format: "{0:n}", width: "150px" }, { field: "shouldPayPrice", title: "应收款", format: "{0:n}", width: "150px" }, { field: "actualPrice", title: "实收款", format: "{0:n}", width: "150px", aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }, ], i = 0; i < n.gridColumns.length; i++) t.push(n.gridColumns[i]);
                        t.push({ field: "overdue", title: "欠款", format: "{0:n}", width: "150px" });
                        f = r.find("#chargeDetailList");
                        f.html("");
                        u = f.kendoGrid({ dataSource: { data: n.pageData, aggregate: n.aggregate }, scrollable: !0, height: e, sortable: !0, selectable: "single", model: { id: "id" }, excel: { fileName: "账单明细(收费明细)_" + moment().format("YYYYMMDD") }, columns: t }).data("kendoGrid") } },
                c = function() { u && u.dataSource.data(n.pageData) },
                o, s, h;
            n.exportExcel = function() { u && u.saveAsExcel() };
            o = function() { var n = $(window).height() - 160;
                $("#detailList").css("height", n) };
            s = function(n) { i.goToCharge(n.patientId) };
            $("#chargeDetailList").on("dblclick", "tr.k-state-selected", function() { var t = u.select(),
                    i = $("tr", u.tbody).index(t),
                    r = n.pageData[i];
                s(r) });
            h = function() { t(function() { var t = $("#statusInput").data("kendoDropDownList");
                        t.value(n.criteria.statusType) }, 50) },
                function() { o();
                    h();
                    n.$watch("pageData", function() { u ? e() : e() }) }() } } }]);
managementModule.directive("personalConsultantWorkSummaryReportView", ["$log", function() { "use strict"; return { restrict: "E", replace: !0, scope: { job: "@" }, controller: "PersonalConsultantWorkSummaryReportCtrl", templateUrl: "/app/management/views/personal-performance/personal-consultant-work-summary-report-view.html", link: function(n, t) { var i = null,
                r = [{ field: "planPrice", aggregate: "sum" }, { field: "actualPrice", aggregate: "sum" }, { field: "actualAmount", aggregate: "sum" }, ],
                u = function() { if (i == null) { var u = $(window).height() - 150;
                        i = t.find("#consultantWorkSummaryList").kendoGrid({ dataSource: { data: n.pageData, aggregate: r }, scrollable: !0, height: u, sortable: !0, selectable: "single", columns: [{ field: "consultantName", title: n.job, width: "80px", footerTemplate: "总计" }, { field: "name", title: "患者姓名", width: "80px" }, { field: "tagStr", title: "自定义标签", width: "150px" }, { field: "privateId", title: "病历号", width: "100px" }, { field: "mobile", title: "手机", width: "110px" }, { field: "startTime", title: "预约时间", width: "140px" }, { field: "payDateTime", title: "收费时间", width: "140px" }, { field: "doctorName", title: "预约医生", width: "100px" }, { field: "checkInType", title: "就诊类型", width: "100px" }, { field: "isChargedStr", title: "是否充值", width: "100px" }, { field: "isDealed", title: "是否成交", width: "100px" }, { field: "reason", title: "未成交原因", width: "140px" }, { field: "transactioncodeStr", title: "预约项目", width: "100px" }, { field: "stateStr", title: "预约状态", width: "80px" }, { field: "planPrice", title: "应收费用", width: "120px", format: "{0:n}", aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }, { field: "actualPrice", title: "实收费用", width: "120px", format: "{0:n}", aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }, { field: "actualAmount", title: "实际实收", width: "120px", format: "{0:n}", aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }, ] }).data("kendoGrid") } else i.dataSource.data(n.pageData) };
            (function() { n.isDealed = -1;
                n.$watch("pageData", function() { n.pageData && n.pageData.length > 0 ? (n.isEmpty = !1, u()) : n.isEmpty = !0 }) })() } } }]);
managementModule.directive("personalNetworkConsultantWorkSummaryReportView", ["$log", "$timeout", "$window", "$q", "$modal", "$filter", "appNav", "enums", "aresDialog", "aresNotification", "permissionProvider", "gridOptionUtil", "loginContext", "patientUtil", "dataDicSvc", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y) { "use strict"; return { restrict: "E", replace: !0, controller: "PersonalNetworkConsultantWorkSummaryReportCtrl", templateUrl: "/app/management/views/personal-performance/personal-network-consultant-work-summary-report-view.html", scope: { officeId: "=" }, link: function(n, t) { var p = null,
                g = Ares.kendoGridUtil(i, n),
                e = f("toMoney"),
                h = function(n) { return function(t) { return t[n] ? moment(t[n]).format("YYYY-MM-DD HH:mm:ss") : "" } },
                nt = function(n) { return function(t) { return t[n] ? moment(t[n]).format("YYYY-MM-DD") : "" } },
                s = function(n) { return function(t) { return t[n] ? e(t[n]) : "" } },
                gt = function(n) { return Ares.priceToFixed(n).toFixed(2) },
                tt = function() { return n.totalConsumptionAmount },
                it = function() { return n.totalPerformance },
                rt = function() { return n.totalActualAmount },
                ut = function() { var n = $(window).height(),
                        i = 145 + t.find("#divCondition").height(),
                        r = n - i,
                        u = r - 73; return Math.max(5, parseInt(u / 40)) },
                ft = [{ field: "name", title: "姓名", width: "120px", footerTemplate: "总计" }, { field: "sexStr", title: "性别", width: "120px", hidden: !0 }, { field: "age", title: "年龄", width: "100px", hidden: !0 }, { field: "mobile", title: "手机", width: "120px" }, { field: "privateId", title: "病历号", width: "140px" }, { field: "onlineConsultantName", title: "网电咨询师", width: "120px" }, { field: "sourceTypeL1", title: "患者来源一级", width: "140px", hidden: !0 }, { field: "sourceTypeL2", title: "患者来源二级", width: "140px", hidden: !0 }, { field: "sourceTypeL3", title: "患者来源三级", width: "140px", hidden: !0 }, { field: "createdUser", title: "创建人", width: "100px" }, { field: "createdTime", title: "创建时间", width: "180px", template: h("createdTime") }, { field: "startTime", title: "预约时间", width: "180px", template: h("startTime") }, { field: "firstVisit", title: "初诊日期", width: "180px", template: nt("firstVisit") }, { field: "apptOffice", title: "预约门店", width: "120px" }, { field: "apptCheckedInType", title: "就诊类型", width: "130px" }, { field: "transactionNames", title: "预约项目", width: "180px" }, { field: "visitOffice", title: "就诊门店", width: "100px" }, { field: "visitTime", title: "就诊时间", width: "180px", template: h("visitTime") }, { field: "superItemCategories", title: "收费大类", width: "100px" }, { field: "itemCategories", title: "收费小类", width: "180px" }, { field: "itemNames", title: "收费项目", width: "180px" }, { field: "consumptionAmount", title: "消费金额", width: "120px", template: s("consumptionAmount"), footerTemplate: tt }, { field: "actualAmount", title: "实际实收", width: "120px", template: s("actualAmount"), footerTemplate: rt }, { field: "performance", title: "绩效收入", width: "120px", template: s("performance"), footerTemplate: it }, { field: "rechargeAmount", title: "充值总金额", width: "120px", template: s("rechargeAmount") }],
                w = function() { var u = t.find("#performanceList"),
                        f = i.innerHeight - (145 + t.find("#divCondition").height()),
                        r = l.getDefaultGridOption({ transport: { read: function(t) { n.pageIndex = t.data.page || 1;
                                    n.pageSize = t.data.pageSize || n.pageSize;
                                    n.searchPerformanceList().then(function(i) { n.allCount = i.allCount;
                                        n.notCheckedInCount = i.notCheckedInCount;
                                        n.notCheckedOutCount = i.notCheckedOutCount;
                                        n.checkedOutCount = i.checkedOutCount;
                                        n.totalConsumptionAmount = e(i.totalConsumptionAmount);
                                        n.totalRechargeAmount = e(i.totalRechargeAmount);
                                        n.totalPerformance = e(i.totalPerformance);
                                        n.totalActualAmount = e(i.totalActualAmount);
                                        ot(i.createdUsers);
                                        t.success({ data: i.items, total: i.totalCount }) }) } }, serverPaging: !0, pageSize: n.pageSize, schema: { data: "data", total: "total" } }, ft, f);
                    r.pageable = l.getPageable(n.pageSize);
                    n.performanceGrid = u.kendoGrid(r).data("kendoGrid") },
                r = function() { var t = n.performanceGrid;
                    t ? (t.dataSource.page() !== 1 && t.dataSource.page(1), t.dataSource.read({ parameter: "value" })) : w() },
                ni = function(t) { return _.find(n.searchData.items, function(n) { return n.id == t }) },
                et = function(t, i) { n.startDate = t;
                    n.endDate = i;
                    r() },
                ot = function(n) { p.dataSource.data(n) },
                b = function() { var i = t.find("#createdUser");
                    i.kendoDropDownList({ dataTextField: "name", dataValueField: "id", optionLabel: "全部", select: function(t) { n.selectedCreatedUserId = this.dataItem(t.item)[this.options.dataValueField] || null;
                            r() } });
                    p = i.data("kendoDropDownList") },
                st = function(t) { n.consultantIds = t;
                    r() },
                ht = function() { n.timeSpan = { startDate: null, endDate: null } },
                ct = function() { c() },
                lt = function() { c() },
                at = function() { c() },
                c = function() { var t = [];
                    n.notCheckedIn && t.push("notCheckedIn");
                    n.notCheckedOut && t.push("notCheckedOut");
                    n.checkedOut && t.push("checkedOut");
                    n.currentToggleTab = t.join(",");
                    r() },
                vt = function() { var t = a.isGroup;
                    t ? (n.selectedOfficeId = null, n.isShowTransactionItem = !1, n.isShowChargeItem = !1) : (n.selectedOfficeId = a.officeId, n.isShowTransactionItem = !0, n.isShowChargeItem = !0);
                    n.isGroup = t;
                    n.selectedIdsStr = "";
                    n.apptIsFirstVisit = "";
                    n.selectedCreatedUserId = "";
                    b();
                    n.defaultconsultantId = n.isPersonalLevel ? "" : a.providerId;
                    n.isShowConsultantDropDown || (n.consultantIds = a.providerId, w()) },
                yt = function() { n.patientPermissionLevel = v.getPatientPermissionLevel();
                    n.isAllLevel = n.patientPermissionLevel == o.PatientPermissionLevel.All;
                    n.isPersonalLevel = n.patientPermissionLevel == o.PatientPermissionLevel.Personal;
                    n.isDepartmentLevel = n.patientPermissionLevel == o.PatientPermissionLevel.Department;
                    n.isShowConsultantDropDown = !n.isPersonalLevel },
                k = function() { n.chargeItems = null;
                    n.chargeItemNames = "全部";
                    n.chargeItemIds = null },
                d = function() { n.transactionCodes = null;
                    n.transactionCodeNames = "全部";
                    n.transactionItems = null },
                pt = function() { var t = angular.copy(n.selectedIdsStr),
                        i = angular.copy(n.selectedNamesMulti),
                        f = u.open({ animation: !0, backdrop: "static", template: "<office-group-dialog-view><\/office-group-dialog-view>", controller: "OfficeGroupDialogCtrl", windowClass: "office-group-dialog", resolve: { host: function() { return { selectMode: "multi", selectScope: "office", selectedIds: t, selectedNames: i } } } });
                    f.result.then(function(t) { if (t && t.selectedIds) { n.selectedIdsStr != t.selectedIds && (k(), d());
                            n.selectedNamesMulti = t.selectedNames;
                            n.selectedIdsStr = t.selectedIds; var i = t.selectedIds.split(","),
                                u = 0;
                            i && (u = i.length);
                            u == 1 ? (n.isShowTransactionItem = !0, n.isShowChargeItem = !0, n.selectedOfficeId = i[0]) : (n.isShowTransactionItem = !1, n.isShowChargeItem = !1, n.selectedOfficeId = null) } else n.selectedNamesMulti = "", n.selectedIdsStr = "", n.isShowTransactionItem = !1, n.isShowChargeItem = !1, n.selectedOfficeId = null, k(), d();
                        n.selectedCreatedUserId = "";
                        b(!0);
                        r() }) },
                wt = function() { var t = angular.copy(n.transactionItems),
                        i;
                    t || (t = []);
                    i = u.open({ animation: !0, backdrop: "static", template: "<item-dialog-view><\/item-dialog-view>", controller: "ItemDialogCtrl", windowClass: "followup-rule-edit-add-dialog", resolve: { host: function() { return { type: "transactioncode", list: t, officeId: n.selectedOfficeId } } } });
                    i.result.then(function(t) { var f, u, e, o, i; if (t) { for (f = t.isSaveAll ? ["全部"] : _.pluck(t.obj, "itemName"), u = "", i = 0; i < f.length; i++) { if (u.length > 10) { u += "..."; break } u += f[i] + "," } for (n.transactionCodeNames = u == "" || u == "全部," ? "全部" : u, angular.forEach(t.obj, function(n) { n.condType = "transactioncode" }), e = t.isSaveAll ? ["全部"] : _.pluck(t.obj, "id"), o = "", i = 0; i < e.length; i++) o += e[i] + ",";
                            n.transactionItems = t.obj;
                            n.transactionCodes = o;
                            r() } }) },
                bt = function() { var t = angular.copy(n.chargeItems),
                        i;
                    t || (t = []);
                    i = u.open({ animation: !0, backdrop: "static", template: "<item-dialog-view><\/item-dialog-view>", controller: "ItemDialogCtrl", windowClass: "followup-rule-edit-add-dialog", resolve: { host: function() { return { type: "chargeItem", list: t, officeId: n.selectedOfficeId } } } });
                    i.result.then(function(t) { var f, u, e, o, i; if (t) { for (f = t.isSaveAll ? ["全部"] : _.pluck(t.obj, "itemName"), u = "", i = 0; i < f.length; i++) { if (u.length > 10) { u += "..."; break } u += f[i] + "," } for (n.chargeItemNames = u == "" || u == "全部," ? "全部" : u, console.info("item.condType", t.obj), angular.forEach(t.obj, function(n) { n.condType = "chargeItem" }), e = t.isSaveAll ? ["全部"] : _.pluck(t.obj, "id"), o = "", i = 0; i < e.length; i++) o += e[i] + ",";
                            n.chargeItems = t.obj;
                            n.chargeItemIds = o;
                            r() } }) },
                kt = function(t) { n.defaultSelect = t;
                    r() },
                dt = function() { y.systemsettingDic.load().then(function(i) { var u = _.filter(i, function(n) { return n.itemType == "就诊类型" });
                        u.unshift({ itemName: "全部" });
                        t.find("#checkInType").kendoDropDownList({ dataTextField: "itemName", dataValueField: "itemName", dataSource: u, select: function(t) { var i = this.dataItem(t.item.index());
                                n.checkInType = i.itemName == "全部" ? null : i.itemName;
                                r() } }) }) };
            (function() { yt();
                dt();
                ht();
                n.searchText = "";
                n.notCheckedIn = !0;
                n.notCheckedOut = !0;
                n.checkedOut = !0;
                n.defaultSelect = 1;
                n.notCheckedInData = ct;
                n.radioCharge = kt;
                n.getNotCheckOutData = lt;
                n.getCheckedOutData = at;
                n.currentToggleTab = "notCheckedIn,notCheckedOut,checkedOut";
                n.allCount = 0;
                n.notCheckedInCount = 0;
                n.notCheckedOutCount = 0;
                n.checkedOutCount = 0;
                n.totalConsumptionAmount = 0;
                n.totalRechargeAmount = 0;
                n.onSearch = r;
                n.onDateChanged = et;
                n.onConsultantChanged = st;
                n.openOfficeGroupMultDialog = pt;
                n.openTransactionItemsDialog = wt;
                n.openChargeItemsDialog = bt;
                n.pageSize = ut();
                vt();
                n.$on("$destroy", function() { g.dispose() }) })() } } }]);
managementModule.directive("personalPerformanceChargeCategoryView", ["$log", "$timeout", "$filter", "$window", "appNav", "dataDicSvc", "providerSvc", function() { "use strict"; return { restrict: "E", replace: !0, controller: "PersonalPerformanceChargeCategoryCtrl", templateUrl: "/app/management/views/personal-performance/personal-performance-charge-category-view.html", scope: { officeId: "=" }, link: function(n, t) { var i = function() { var i = $(window).height() - 170;
                t.find("#doctorChargeCategoryReportList").html("");
                t.find("#doctorChargeCategoryReportList").kendoGrid({ dataSource: { data: n.dataSource, aggregate: n.aggregate }, scrollable: !0, height: i, sortable: !0, selectable: "single", model: { id: "id" }, excel: { fileName: "收费大类_" + moment().format("YYYYMMDD") }, columns: n.gridColumns }).data("kendoGrid") };
            n.exportExcel = function() { var n = t.find("#doctorChargeCategoryReportList").data("kendoGrid");
                    n && n.saveAsExcel() },
                function() { n.$watch("dataSource", function() { n.dataSource && (t.find("#doctorChargeCategoryReportList").show(), i());
                        n.dataSource && n.dataSource.length <= 0 && t.find("#doctorChargeCategoryReportList").hide() }) }() } } }]);
managementModule.directive("personalPerformanceChargeClassView", ["$log", "$timeout", "$filter", "$window", "appNav", "enums", function() { "use strict"; return { restrict: "E", replace: !0, controller: "PersonalPerformanceChargeClassCtrl", templateUrl: "/app/management/views/personal-performance/personal-performance-charge-class-view.html", scope: { officeId: "=" }, link: function(n, t) { var r, i, u = !1,
                f, e;
            $(".isHideData").hide();
            $("#daysBeforeTodayInput").change(function() { $("#daysBeforeTodayInput").val() == "自定义" ? $(".isHideData").show() : $(".isHideData").hide() });
            f = function() { n.pageData && (u = !0, r = t.find("#doctorChargeClassReportList"), i = r.kendoGrid({ dataSource: { data: n.pageData }, scrollable: !1, selectable: "single", sortable: !0, model: { id: "id" }, columns: n.gridColumns }).data("kendoGrid")) };
            e = function() { i && i.dataSource.data(n.pageData) };
            n.exportExcel = function() { i && i.saveAsExcel() },
                function() { n.$watch("pageData", function() { if (u) { var t = $("#doctorChargeClassReportList").data("kendoGrid");
                            t.dataSource.data(n.pageData) } else f() }) }() } } }]);
managementModule.directive("personalPerformanceChargeDetailView", ["$log", "$timeout", "$filter", "$window", "loginContext", "dataDicSvc", function(n, t, i, r, u) { "use strict"; return { restrict: "E", replace: !0, controller: "PersonalPerformanceChargeDetailCtrl", templateUrl: "/app/management/views/personal-performance/personal-performance-charge-detail-view.html", scope: { officeId: "=" }, link: function(n, t) { var i = function() { var i = $(window).height() - 170;
                    t.find("#doctorChargeDetailReportList").html("");
                    t.find("#doctorChargeDetailReportList").kendoGrid({ dataSource: { data: n.pageData, schema: { model: { id: "id", fields: { doctorName: { type: "string" }, nurseName: { type: "string" }, itemName: { type: "string" }, itemCount: { type: "number" }, actualPrice: { type: "number" }, planPrice: { type: "number" } } } }, aggregate: [{ field: "itemCount", aggregate: "sum" }, { field: "actualPrice", aggregate: "sum" }, { field: "planPrice", aggregate: "sum" }] }, excel: { fileName: "收费明细_" + moment().format("YYYYMMDD") }, scrollable: !0, height: i, sortable: !0, selectable: "single", model: { id: "id" }, columns: r() }).data("kendoGrid") },
                r = function() { var t = [{ field: "itemName", title: "收费项", width: "300px" }, { field: "itemCount", title: "数量", width: "80px", format: "{0:n}", aggregates: ["sum"], footerTemplate: "#=Ares.priceToFixed(sum)#" }]; return t.splice(0, 0, { field: "providerName", title: u.providerJob, width: "80px", footerTemplate: "总计" }), n.selectActualPrice ? t.splice(3, 0, { field: "actualPrice", title: "金额", width: "80px", format: "{0:n}", aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }) : t.splice(3, 1, { field: "planPrice", title: "金额", width: "80px", format: "{0:n}", aggregates: ["sum"], footerTemplate: "#=kendo.toString(sum,'c2')#" }), t };
            n.exportExcel = function() { var n = t.find("#doctorChargeDetailReportList").data("kendoGrid");
                    n && n.saveAsExcel() },
                function() { n.$watch("pageData", function() { n.pageData && n.pageData.length > 0 && (t.find("#doctorChargeDetailReportList").show(), i());
                        n.pageData && n.pageData.length <= 0 && t.find("#doctorChargeDetailReportList").hide() }) }() } } }]);
managementModule.directive("personalPerformanceDoctorApptView", ["$log", "$timeout", "$filter", "$window", "appNav", "dataDicSvc", "providerSvc", function(n, t, i, r) { "use strict"; return { restrict: "E", replace: !0, controller: "PersonalPerformanceDoctorApptCtrl", templateUrl: "/app/management/views/personal-performance/personal-performance-doctor-appt-view.html", scope: { officeId: "=" }, link: function(n, t) { var i, u, f = function() { var f = r.innerHeight - 170;
                i = t.find("#doctorApptCountReportList");
                i.html("");
                u = i.kendoGrid({ dataSource: { data: n.pageData, aggregate: n.aggregates }, scrollable: !1, sortable: !0, height: f, selectable: "single", model: { id: "id" }, excel: { fileName: "就诊人次_" + moment().format("YYYYMMDD") }, columns: n.columns }).data("kendoGrid") };
            n.exportExcel = function() { var n = $("#doctorApptCountReportList").data("kendoGrid");
                    n && n.saveAsExcel() },
                function() { n.$watch("pageData", function() { f() }) }() } } }]);
managementModule.directive("personalPerformanceHomeView", ["$log", "$timeout", "$filter", "$window", "appNav", "enums", "officeOptionSvc", "loginContext", function(n, t, i, r, u, f, e, o) { "use strict"; return { restrict: "E", templateUrl: "/app/management/views/personal-performance/personal-performance-home-view.html", scope: { officeId: "=" }, link: function(n) { var t = function() { var t = [new u.TabItem("personalperformance.chargeDetailView", "收费明细", "icon-bag", null), new u.TabItem("personalperformance.chargeDetail", "账单明细（收入明细）", "icon-calculator", null), new u.TabItem("personalperformance.chargeCategoryView", "收费大类", "icon-calculator", null), ];
                e.getOfficeOption(e.optionKeys.EnableConsultantDiagnose).then(function() { n.states = t;
                    o.isGroup || o.providerJob == "护士" || (t.push(new u.TabItem("personalperformance.doctorApptView", "就诊人次", "icon-calculator", null)), n.states = t);
                    o.providerJob == "咨询师" && (n.states = [new u.TabItem("personalperformance.consultantView", "工作汇总", "icon-calculator", null)]);
                    o.providerJob == "牙医助理" && (n.states = [new u.TabItem("personalperformance.assistantView", "工作汇总", "icon-calculator", null)]);
                    o.providerJob == "网电营销" && (n.states = [new u.TabItem("personalperformance.networkConsultantView", "工作汇总", "icon-calculator", null)]);
                    o.providerJob == "前台" && (n.states = [new u.TabItem("personalperformance.chargeDetail", "账单明细（收入明细）", "icon-calculator", null)]) }) };
            (function() { t() })() } } }]);
managementModule.directive("patientReferralReportView", ["$log", "$window", "$modal", "$timeout", "$q", "kendoUtil", "appNav", "managementDialogUtil", "loginContext", function(n, t, i, r, u, f, e, o, s) { "use strict"; return { templateUrl: "/app/management/views/referral/patient-referral-report-view.html", controller: "PatientReferralReportCtrl", link: function(n, i) { var u = [{ field: "officeName", title: "所属机构", width: "100px" }, { field: "name", title: "推荐人姓名", width: "100px", template: function(n) { var t = n.name,
                            i = n.id; return '<span class="enyo-text-primary oper-button patient-info" id="' + i + '" title="查看患者信息" >' + t + "<\/span>" } }, { field: "", title: "创建日期", width: "110px", template: function(n) { return f.dateFormat(n.recordCreatedTime) } }, { field: "privateId", title: "病历号", width: "100px" }, { field: "mobile", title: "手机号码", width: "100px" }, { field: "referralCount", title: "推荐人数", width: "60px", template: function(n) { var t = n.referralCount,
                            i = n.id; return '<span class="enyo-text-primary oper-button patient-referal-count" id="' + i + '" title="查看推荐人数" >' + t + "<\/span>" } }, { field: "referralPoint", title: "激励积分", width: "65px" }, { field: "point", title: "当前积分余额", width: "85px", template: function(n) { var t = n.point,
                            i = n.id; return '<span class="enyo-text-primary oper-button patient-point-info" id="' + i + '" title="查看积分余额" >' + t + "<\/span>" } }],
                h, r = function() { n.getPatientReferral().then(function(r) { n.patientReferralList = r; var f = angular.copy(u),
                            c = t.innerHeight - 160 - (window.Ares3 ? 50 : 0);
                        h = i.find("#patientReferralGrid").kendoGrid({ dataSource: { data: r.items }, height: c, model: { id: "refereeId" }, columns: f, sortable: !1, resizable: !0, reorderable: !0, columnMenu: !1 }).data("kendoGrid");
                        h.table.on("click", ".patient-info", function() { var n = $(this).attr("id");
                            e.goToPatient(n) });
                        h.table.on("click", ".patient-point-info", function() { var n = $(this).attr("id");
                            o.openTransactionHisotryDialog(n) });
                        h.table.on("click", ".patient-referal-count", function() { var t = $(this).attr("id"),
                                i = n.isGroup ? n.selectedOfficeIdsArray : [s.officeId],
                                r = { id: t };
                            o.openRefereeDialog(r, i) }) }) },
                c = function(t) { n.criteria.pageIndex = t;
                    r() },
                l = function(t) { n.criteria.pageSize = t;
                    r() },
                a = function() { r() },
                v = function() { r() },
                y = function(t) { n.selectedOfficeIdsArray = _.pluck(t, "officeId");
                    r() };
            (function() { n.onOfficeSelected = y;
                n.onPageChanged = c;
                n.onPageSizeChanged = l;
                n.onSearch = a;
                u = n.isGroup ? u : u.slice(1);
                n.loadOffices().then(function() { v() }) })() } } }]);
managementModule.directive("patientReferralRewardReportView", ["$log", "$window", "$modal", "$timeout", "$q", "enums", "kendoUtil", "appNav", "$filter", function(n, t, i, r, u, f, e, o, s) { "use strict"; return { templateUrl: "/app/management/views/referral/patient-referral-reward-report-view.html", controller: "PatientReferralRewardReportCtrl", scope: { ruleType: "@" }, link: function(n, i) { var c = function(t) { n.columns = t == f.ReferralRuleType.Visit ? [{ field: "name", title: "患者姓名", width: "120px", template: function(n) { var t = n.name,
                                i = n.patientId; return '<span class="enyo-text-primary oper-button patient-info" id="' + i + '" title="查看患者信息" >' + t + "<\/span>" } }, { field: "privateId", title: "病历号", width: "120px" }, { field: "mobile", title: "手机号码", width: "120px" }, { field: "ruleType", title: "激励类型", width: "100px", template: function(n) { return s("toReferralRuleTypeStr")(n.ruleType) } }, { field: "actionType", title: "激励方式", width: "100px", template: function(n) { return s("toReferralRuleActionTypeStr")(n.actionType) } }, { field: "officeName", title: "所属机构", width: "100px" }, { field: "visitTime", title: "到店时间", width: "150px", template: function(n) { return e.dateFormat(n.visitTime, "YYYY-MM-DD HH:mm") } }, { field: "condValue", title: "本机构到店次数", width: "120px" }, { field: "orderTime", title: "激励时间", width: "150px", template: function(n) { return e.dateFormat(n.orderTime, "YYYY-MM-DD HH:mm") } }, { field: "level1RefereeName", title: "一级推荐人", width: "100px", template: function(n) { var t = n.level1RefereeName,
                                i = n.level1RefereeId; return '<span class="enyo-text-primary oper-button patient-info" id="' + i + '" title="查看患者信息" >' + t + "<\/span>" } }, { field: "level1RefereeMobile", title: "一级推荐人手机号", width: "160px" }, { field: "level1ActionData", title: "激励积分", width: "100px" }, { field: "level2RefereeName", title: "二级推荐人", width: "100px", template: function(n) { var r = n.level2RefereeName,
                                t = n.level2RefereeId,
                                i = ""; return t && (i = '<span class="enyo-text-primary oper-button patient-info" id="' + t + '" title="查看患者信息" >' + r + "<\/span>"), i } }, { field: "level2RefereeMobile", title: "二级推荐人手机号", width: "160px" }, { field: "level2ActionData", title: "激励积分", width: "100px" }] : t == f.ReferralRuleType.Payment ? [{ field: "name", title: "被推荐人姓名", width: "120px", template: function(n) { var t = n.name,
                                i = n.patientId; return '<span class="enyo-text-primary oper-button patient-info" id="' + i + '" title="查看患者信息" >' + t + "<\/span>" } }, { field: "officeName", title: "所属机构", width: "100px" }, { field: "privateId", title: "病历号", width: "120px" }, { field: "mobile", title: "手机号码", width: "120px" }, { field: "ruleType", title: "激励类型", width: "100px", template: function(n) { return s("toReferralRuleTypeStr")(n.ruleType) } }, { field: "actionType", title: "激励方式", width: "100px", template: function(n) { return s("toReferralRuleActionTypeStr")(n.actionType) } }, { field: "visitTime", title: "消费时间", width: "150px", template: function(n) { return e.dateFormat(n.visitTime, "YYYY-MM-DD HH:mm") } }, { field: "condValue", title: "消费金额", width: "120px" }, { field: "orderTime", title: "激励时间", width: "150px", template: function(n) { return e.dateFormat(n.orderTime, "YYYY-MM-DD HH:mm") } }, { field: "level1RefereeName", title: "一级推荐人", width: "100px", template: function(n) { var t = n.level1RefereeName,
                                i = n.level1RefereeId; return '<span class="enyo-text-primary oper-button patient-info" id="' + i + '" title="查看患者信息" >' + t + "<\/span>" } }, { field: "level1RefereeMobile", title: "一级推荐人手机号", width: "160px" }, { field: "level1ActionData", title: "激励积分", width: "100px" }, { field: "level2RefereeName", title: "二级推荐人", width: "100px", template: function(n) { var r = n.level2RefereeName,
                                t = n.level2RefereeId,
                                i = ""; return t && (i = '<span class="enyo-text-primary oper-button patient-info" id="' + t + '" title="查看患者信息" >' + r + "<\/span>"), i } }, { field: "level2RefereeMobile", title: "二级推荐人手机号", width: "160px" }, { field: "level2ActionData", title: "激励积分", width: "100px" }] : [{ field: "level1RefereeName", title: "推荐人姓名", width: "120px", template: function(n) { var t = n.level1RefereeName,
                                i = n.level1RefereeId; return '<span class="enyo-text-primary oper-button patient-info" id="' + i + '" title="查看患者信息" >' + t + "<\/span>" } }, { field: "level1RefereeOfficeName", title: "所属机构", width: "100px" }, { field: "level1RefereePrivateId", title: "病历号", width: "120px" }, { field: "level1RefereeMobile", title: "手机号码", width: "120px" }, { field: "ruleType", title: "激励类型", width: "120px", template: function(n) { return s("toReferralRuleTypeStr")(n.ruleType) } }, { field: "actionType", title: "激励方式", width: "100px", template: function(n) { return s("toReferralRuleActionTypeStr")(n.actionType) } }, { field: "condValue", title: "推荐消费金额", width: "120px" }, { field: "orderTime", title: "激励时间", width: "150px", template: function(n) { return e.dateFormat(n.orderTime, "YYYY-MM-DD HH:mm") } }, { field: "point", title: "激励积分", width: "120px" }, { field: "giftCertificateName", title: "激励优惠券", width: "150px" }] },
                r, u = function() { n.getPatientReferralReward().then(function(u) { n.patientReferralRewardList = u; var e = angular.copy(n.columns),
                            f = t.innerHeight - 150 - (window.Ares3 ? 65 : 0);
                        r ? r.setOptions({ dataSource: { data: u.items }, height: f }) : r = i.find("#patientReferralRewardGrid").kendoGrid({ dataSource: { data: u.items }, height: f, model: { id: "patientId" }, columns: e, sortable: !1, resizable: !0, reorderable: !0, columnMenu: !1 }).data("kendoGrid");
                        r.table.on("click", ".patient-info", function() { var n = $(this).attr("id");
                            o.goToPatient(n) }) }) },
                l = function(t) { n.criteria.pageIndex = t;
                    u() },
                a = function(t) { n.criteria.pageSize = t;
                    u() },
                v = function() { u() },
                h = function() { n.patient = null;
                    n.referee = null;
                    b();
                    u() },
                y = function() { n.patient = null;
                    n.criteria.patientId = null },
                p = function() { n.referee = null;
                    n.criteria.refereeId = null },
                w = function() { n.patient = null;
                    n.referee = null;
                    n.criteria.visitCount = "";
                    n.criteria.patientId = null;
                    n.criteria.refereeId = null;
                    h() },
                b = function() { n.timeSpan = { startDate: null, endDate: null } },
                k = function(t) { var i = "";
                    t = parseInt(n.ruleType); switch (t) {
                        case f.ReferralRuleType.Visit:
                            i = "到店时间"; break;
                        case f.ReferralRuleType.Payment:
                            i = "消费时间"; break;
                        case f.ReferralRuleType.TotalPayment:
                            i = "激励时间"; break;
                        default:
                            i = "" } return i },
                d = function(t) { n.patient = t },
                g = function(t) { n.referee = t };
            (function() { n.onRefereeSelected = g;
                n.onPatientSelected = d;
                n.onPageChanged = l;
                n.onPageSizeChanged = a;
                n.onSearch = v;
                n.onRefresh = w;
                n.noop = _.noop;
                n.onPatientCleared = y;
                n.onRefereeCleared = p;
                n.timeTitle = k(n.ruleType);
                n.isTotalPaymentRuleType = n.ruleType == f.ReferralRuleType.TotalPayment;
                c(n.ruleType);
                h() })() } } }]);
managementModule.directive("patientReferralVisitReportView", ["$log", "$window", "$modal", "$timeout", "$q", "kendoUtil", "appNav", "$filter", function(n, t, i, r, u, f, e, o) { "use strict"; return { templateUrl: "/app/management/views/referral/patient-referral-visit-report-view.html", controller: "PatientReferralVisitReportCtrl", link: function(n, i) { var s = [{ field: "officeName", title: "所属机构", width: "120px" }, { field: "name", title: "患者姓名", width: "100px", template: function(n) { var t = n.name,
                            i = n.patientId; return '<span class="enyo-text-primary oper-button patient-info" id="' + i + '" title="查看患者信息" >' + t + "<\/span>" } }, { field: "privateId", title: "病历号", width: "120px" }, { field: "mobile", title: "手机号", width: "120px" }, { field: "", title: "创建时间", width: "140px", template: function(n) { return o("toLongDateMMString")(n.recordCreatedTime) } }, { field: "recordCreatedUserName", title: "创建人", width: "100px" }, { field: "firstVisit", title: "首次到店日期", width: "140px", template: function(n) { return o("toDateString")(n.firstVisit) } }, { field: "lastVisit", title: "最后一次到店时间", width: "140px", template: function(n) { return o("toLongDateMMString")(n.lastVisit) } }, { field: "visitCount", title: "到店次数", width: "80px" }, { field: "refereeName", title: "推荐人姓名", width: "100px", template: function(n) { var t = n.refereeName,
                            i = n.refereeId; return '<span class="enyo-text-primary oper-button patient-info" id="' + i + '" title="查看患者信息" >' + t + "<\/span>" } }, { field: "refereeMobile", title: "推荐人手机号", width: "120px" }, { field: "refereePrivateId", title: "推荐人病历号", width: "120px" }, { field: "refereeOfficeName", title: "推荐人所属机构", width: "120px" }],
                u, r = function() { n.getPatientReferralVisit().then(function(r) { n.patientReferralVisitList = r; var o = angular.copy(s),
                            f = t.innerHeight - (i.find(".patient-referral-visit-search").offset().top + i.find(".patient-referral-visit-search").height()) - 70;
                        u ? u.setOptions({ dataSource: { data: r.items }, height: f }) : u = i.find("#patientReferralVisitGrid").kendoGrid({ dataSource: { data: r.items }, height: f, model: { id: "patientId" }, columns: o, sortable: !1, resizable: !0, reorderable: !0, columnMenu: !1 }).data("kendoGrid");
                        u.table.on("click", ".patient-info", function() { var n = $(this).attr("id");
                            e.goToPatient(n) }) }) },
                h = function(t) { n.criteria.pageIndex = t;
                    r() },
                c = function(t) { n.criteria.pageSize = t;
                    r() },
                l = function() { r() },
                a = function() { n.criteria.searchText = "";
                    n.criteria.visitCount = "";
                    f() },
                f = function() { v();
                    n.loadOffices().then(function() { r() }) },
                v = function() { n.firstVisitTimeSpan = { startDate: null, endDate: null };
                    n.lastVisitTimeSpan = { startDate: null, endDate: null };
                    n.createdTimeSpan = { startDate: null, endDate: null } },
                y = function(t) { n.selectedOfficeIdsArray = _.pluck(t, "officeId");
                    r() };
            (function() { n.onOfficeSelected = y;
                n.onPageChanged = h;
                n.onPageSizeChanged = c;
                n.onSearch = l;
                n.onRefresh = a;
                n.initialize = !0;
                f() })() } } }]);
managementModule.directive("referralHomeView", ["$log", "appNav", "$modal", "loginContext", "moduleOptionProvider", function(n, t, i, r, u) { "use strict"; return { restrict: "E", templateUrl: "/app/management/views/referral/referral-home-view.html", link: function(n) { var i = function() { var e = [new t.TabItem("referralCenter.arrivalReferralConfig", "到店激励", "", "")],
                    i, s, f, o;
                u.isReferralPaymentRuleEnabled() && (e.push(new t.TabItem("referralCenter.paymentReferralConfig", "单笔消费激励", "", "")), e.push(new t.TabItem("referralCenter.totalPaymentReferralConfig", "累计消费激励", "", "")));
                i = [new t.TabItem("", "推荐激励规则配置", "", "", e), new t.TabItem("referralCenter.patientReferralReport", "推荐人明细", "", ""), new t.TabItem("referralCenter.patientReferralVisitReport", "被推荐人明细", "", "")];
                r.isGroup || i.splice(0, 0, new t.TabItem("referralCenter.dashboard", "概览", "", ""));
                s = r.isGroup ? 0 : 1;
                i[s].expanded = !0;
                r.isGroup || (f = [new t.TabItem("referralCenter.patientVisitReferralRewardReport", "到店激励明细", "", "")], u.isReferralPaymentRuleEnabled() && (f.push(new t.TabItem("referralCenter.patientPaymentReferralRewardReport", "单笔消费激励明细", "", "")), f.push(new t.TabItem("referralCenter.patientTotalPaymentReferralRewardReport", "累计消费激励明细", "", ""))), o = new t.TabItem("", "推荐激励明细", "", "", f), o.expanded = !0, i.push(o));
                n.states = i };
            (function() { i() })() } } }]);
var management;
(function() { "use strict"; var n = function() {
        function n(n, t, i, r, u, f) { var e = this;
            this.echartsUtil = n;
            this.$filter = t;
            this.$modal = i;
            this.$rootScope = r;
            this.loginContext = u;
            this.$timeout = f;
            this.templateUrl = "/app/management/views/referral/referral-report-dashboard-view.html";
            this.replace = !0;
            this.restrict = "E";
            this.controller = "ReferralReportDashboardCtrl";
            this.link = function(n, t) { var i = function(n) { var i = t.find("#referral-report-dashboard-referral-count-trend")[0],
                            r = e.echartsUtil.initLineChart(i, n, !1) },
                    r = function(n) { var i = t.find("#referral-report-dashboard-referral-amount-trend")[0],
                            r = e.echartsUtil.initLineChart(i, n, !0) };
                (function() { n.initReferralCountTrend = i;
                    n.initReferralAmountTrend = r;
                    e.echartsUtil.onInit(function() { n.loadSummaryReport();
                        n.loadRankReport();
                        n.loadTrendReport() }) })() } } return n.$inject = ["echartsUtil", "$filter", "$modal", "$rootScope", "loginContext", "$timeout"], n }();
    supplychainReportModule.directive("referralReportDashboardView", Ares.tsDirective(n)) })(management || (management = {}));
var management;
(function() { "use strict"; var n = function() {
        function n(n) { var t = this;
            this.$timeout = n;
            this.templateUrl = "/app/management/views/referral/referral-arrival-config/referral-arrival-config-view.html";
            this.restrict = "E";
            this.replace = !0;
            this.scope = !0;
            this.controller = "ReferralArrivalConfigCtrl";
            this.link = function(n, i) { var r = function() { t.$timeout(function() { i.find('[data-toggle="tooltip"]').tooltip({ container: ".referral-arrival-config-view" }) }) };
                (function() { n.initTooltip = r;
                    r() })() } } return n.$inject = ["$timeout"], n }();
    managementModule.directive("referralArrivalConfigView", Ares.tsDirective(n)) })(management || (management = {}));
var management;
(function() { "use strict"; var n = function() {
        function n(n, t, i, r, u, f, e) { this.$scope = n;
            this.referralSvc = t;
            this.enums = i;
            this.aresNotification = r;
            this.aresConfirmDialog = u;
            this.appNav = f;
            this.$rootScope = e;
            this.getReferralConfig();
            n.uiState = { isEdit: !1, isValidDayEnabled: !1, isNewWxEnabled: e.isNewWxEnabled } } return n.prototype.getReferralConfig = function() { var n = this;
            this.referralSvc.getReferralConfig(this.enums.ReferralRuleType.Visit).then(function(t) { var i = t.data;
                n.$scope.referralConfig = i ? i : { isEnabled: !1, validDayCount: -1, actionType: n.enums.ReferralRuleActionType.Point, enabledRuleType: n.enums.ReferralRuleType.Visit, rules: [{ ruleType: n.enums.ReferralRuleType.Visit, condType: n.enums.ReferralRuleCondType.VisitCount, level1Benchmark: 0, level1ActionData1: 0, level1ActionData2: 0, level2Benchmark: 0, level2ActionData1: 0, level2ActionData2: 0 }] };
                n.$scope.uiState.isValidDayEnabled = n.$scope.referralConfig.validDayCount > 0;
                n.cachedConfig = angular.copy(n.$scope.referralConfig) }) }, n.prototype.formatReferralConfig = function() { var n = this.$scope.referralConfig,
                t;
            this.$scope.uiState.isValidDayEnabled || (n.validDayCount = -1);
            n.rules[0].level2Benchmark = n.rules[0].level1Benchmark;
            t = { isEnabled: n.isEnabled, ruleType: n.enabledRuleType, condType: this.enums.ReferralRuleCondType.VisitCount, actionType: n.actionType };
            _.each(n.rules, function(n) { n = _.extend(n, t) }) }, n.prototype.save = function() { var n = this; if (this.$scope.uiState.isValidDayEnabled && this.$scope.referralConfig.validDayCount < 1) { this.aresConfirmDialog.warn({ message: "奖励有效期天数应大于0" }); return } this.formatReferralConfig();
            this.referralSvc.setReferralConfig(this.$scope.referralConfig).success(function(t) { n.$scope.referralConfig = t;
                n.$scope.uiState.isValidDayEnabled = n.$scope.referralConfig.validDayCount > 0;
                n.aresNotification.success("保存成功");
                n.$scope.uiState.isEdit = !1;
                n.$scope.initTooltip() }) }, n.prototype.cancel = function() { this.$scope.referralConfig = this.cachedConfig;
            this.$scope.uiState.isEdit = !1;
            this.$scope.initTooltip() }, n.prototype.edit = function() { this.$scope.uiState.isEdit = !0;
            this.$scope.initTooltip() }, n.prototype.onCountChanged = function(n, t) { this.$scope.uiState.isEdit && (n[t] = parseInt(n[t]), n[t] < 1 && (n[t] = t == "validDayCount" ? null : 0)) }, n.prototype.setReferralRule = function() { this.appNav.goToState("scrmCenter", { action: "invite" }) }, n.$inject = ["$scope", "referralSvc", "enums", "aresNotification", "aresConfirmDialog", "appNav", "$rootScope"], n }();
    managementModule.controller("ReferralArrivalConfigCtrl", Ares.tsController(n)) })(management || (management = {}));
var management;
(function() { "use strict"; var n = function() {
        function n(n) { var t = this;
            this.$timeout = n;
            this.templateUrl = "/app/management/views/referral/referral-payment-config/referral-payment-config-view.html";
            this.restrict = "E";
            this.replace = !0;
            this.scope = !0;
            this.controller = "ReferralPaymentConfigCtrl";
            this.link = function(n, i) { var r = function() { t.$timeout(function() { i.find('[data-toggle="tooltip"]').tooltip({ container: ".referral-payment-config-view" }) }) };
                (function() { n.initTooltip = r;
                    r() })() } } return n.$inject = ["$timeout"], n }();
    managementModule.directive("referralPaymentConfigView", Ares.tsDirective(n)) })(management || (management = {}));
var management;
(function() { "use strict"; var n = function() {
        function n(n, t, i, r, u, f, e, o, s) { this.$scope = n;
            this.$q = t;
            this.enums = i;
            this.referralSvc = r;
            this.officeOptionSvc = u;
            this.aresNotification = f;
            this.aresConfirmDialog = e;
            this.appNav = o;
            this.$rootScope = s;
            n.uiState = { isEdit: !1, isValidDayEnabled: !1, isStepModeEnabled: !0, isNewWxEnabled: s.isNewWxEnabled };
            this.getReferralConfig() } return n.prototype.getReferralConfig = function() { var n = this;
            this.referralSvc.getReferralConfig(this.enums.ReferralRuleType.Payment).then(function(t) { var i = t.data;
                n.$scope.referralConfig = i ? i : { isEnabled: !1, validDayCount: -1, actionType: n.enums.ReferralRuleActionType.Point, enabledRuleType: n.enums.ReferralRuleType.Payment, isWithdrawRequired: !1, rules: [{ ruleType: n.enums.ReferralRuleType.Payment, condType: n.enums.ReferralRuleCondType.PaidAmount, level1Benchmark: 0, level1ActionData1: 0, level1ActionData2: 0, level2Benchmark: 0, level2ActionData1: 0, level2ActionData2: 0 }] };
                n.$scope.uiState.isValidDayEnabled = n.$scope.referralConfig.validDayCount > 0;
                n.$scope.uiState.isStepModeEnabled = !0;
                n.$scope.referralConfig && n.$scope.referralConfig.rules.length > 0 && n.$scope.referralConfig.rules[0].level1Benchmark == -1 && n.$scope.referralConfig.rules[0].level2Benchmark == -1 && (n.$scope.uiState.isStepModeEnabled = !1);
                n.cachedConfig = angular.copy(n.$scope.referralConfig) }) }, n.prototype.formatReferralConfig = function() { var n = this.$scope.referralConfig,
                t;
            this.$scope.uiState.isValidDayEnabled || (n.validDayCount = -1);
            n.rules[0].level2Benchmark = n.rules[0].level1Benchmark;
            this.$scope.uiState.isStepModeEnabled || (n.rules[0].level1Benchmark = -1, n.rules[0].level2Benchmark = -1, n.rules[0].level1ActionData2 = n.rules[0].level1ActionData1, n.rules[0].level2ActionData2 = n.rules[0].level2ActionData1);
            t = { isEnabled: n.isEnabled, ruleType: n.enabledRuleType, condType: this.enums.ReferralRuleCondType.PaidAmount, actionType: n.actionType, isWithdrawRequired: n.isWithdrawRequired };
            _.each(n.rules, function(n) { n = _.extend(n, t) }) }, n.prototype.save = function() { var n = this; if (this.$scope.uiState.isValidDayEnabled && this.$scope.referralConfig.validDayCount < 1) { this.aresConfirmDialog.warn({ message: "奖励有效期天数应大于0" }); return } if (this.$scope.referralConfig.rules && this.$scope.referralConfig.rules.length < 1) { this.aresConfirmDialog.warn({ message: "请填写激励规则" }); return } if (this.$scope.uiState.isStepModeEnabled && this.$scope.referralConfig.rules[0] != null && this.$scope.referralConfig.rules[0].level1Benchmark <= 0) { this.aresConfirmDialog.warn({ message: "单笔消费金额应大于0" }); return } this.formatReferralConfig();
            this.referralSvc.setReferralConfig(this.$scope.referralConfig).success(function(t) { n.$scope.referralConfig = t;
                n.$scope.uiState.isValidDayEnabled = n.$scope.referralConfig.validDayCount > 0;
                n.aresNotification.success("保存成功");
                n.$scope.uiState.isEdit = !1;
                n.$scope.initTooltip() }) }, n.prototype.cancel = function() { this.$scope.referralConfig = this.cachedConfig;
            this.$scope.uiState.isEdit = !1;
            this.$scope.initTooltip() }, n.prototype.edit = function() { this.$scope.uiState.isEdit = !0;
            this.$scope.initTooltip() }, n.prototype.onCountChanged = function(n, t) { this.$scope.uiState.isEdit && (n[t] = parseInt(n[t]), n[t] < 1 && (n[t] = t == "validDayCount" ? null : 0)) }, n.prototype.onStepModeChanged = function() { var n = this.$scope;
            n.uiState.isStepModeEnabled ? (n.referralConfig.rules[0].level1Benchmark = 0, n.referralConfig.rules[0].level2Benchmark = 0) : (n.referralConfig.rules[0].level1Benchmark = -1, n.referralConfig.rules[0].level2Benchmark = -1) }, n.prototype.setReferralRule = function() { this.appNav.goToState("scrmCenter", { action: "invite" }) }, n.$inject = ["$scope", "$q", "enums", "referralSvc", "officeOptionSvc", "aresNotification", "aresConfirmDialog", "appNav", "$rootScope"], n }();
    managementModule.controller("ReferralPaymentConfigCtrl", Ares.tsController(n)) })(management || (management = {}));
var management;
(function() { "use strict"; var n = function() {
        function n(n, t) { var i = this;
            this.$timeout = n;
            this.enums = t;
            this.templateUrl = "/app/management/views/referral/referral-total-payment-config/referral-total-payment-config-view.html";
            this.restrict = "E";
            this.replace = !0;
            this.scope = !0;
            this.controller = "ReferralTotalPaymentConfigCtrl";
            this.link = function(n, t) { var r = null,
                    u = function() { i.$timeout(function() { t.find('[data-toggle="tooltip"]').tooltip({ container: ".referral-total-payment-config-view" }) }) },
                    e = function() { n.uiState.isShowErrorMessage = !1 },
                    o = function() { n.referralConfig.rules[0].level1ActionData2 = 0;
                        n.referralConfig.actionType == i.enums.ReferralRuleActionType.GiftCertificate && (n.giftCertificate = null, f(n.enableGiftCertificates, n.referralConfig.rules[0].level1ActionData2)) },
                    f = function(u, f) { var e = i;
                        e.$timeout(function() { r = t.find("input.advance-search-dropdown").kendoDropDownList({ dataTextField: "certificateName", dataValueField: "id", template: '<div class="search-config-template"><table style="width:100%;"><tr><td><span>#: data.certificateName #<\/span> <span style="margin-left:10px;">库存:#: (data.count - data.drawCount) #<\/span><\/td><\/tr><\/table><\/div>', dataSource: u, value: f, optionLabel: "请选择", filter: "contains", select: function(t) { var i = this;
                                    e.$timeout(function() { var u = i,
                                            r = u.dataItem(t.item) || null;
                                        r && r.id ? (n.referralConfig.rules[0].level1ActionData2 = r && r.id ? r.id : 0, n.giftCertificate = r) : (n.referralConfig.rules[0].level1ActionData2 = 0, n.giftCertificate = null);
                                        n.giftCertificate && (n.giftCertificate.leftCount = n.giftCertificate.count - n.giftCertificate.drawCount, n.setStatus(n.giftCertificate, !1)) }) }, height: 300 }).data("kendoDropDownList");
                            f ? r.value(f) : r.value(null);
                            n.referralConfig.rules[0].level1ActionData2 = r.value() }) };
                (function() { n.changeActionType = o;
                    n.close = e;
                    n.initTooltip = u;
                    n.initGiftCertificateDropDown = f;
                    u() })() } } return n.$inject = ["$timeout", "enums"], n }();
    managementModule.directive("referralTotalPaymentConfigView", Ares.tsDirective(n)) })(management || (management = {}));
var management;
(function() { "use strict"; var n = function() {
        function n(n, t, i, r, u, f, e, o, s, h) { this.$scope = n;
            this.$q = t;
            this.enums = i;
            this.referralSvc = r;
            this.officeOptionSvc = u;
            this.membershipSvc = f;
            this.aresNotification = e;
            this.aresConfirmDialog = o;
            this.appNav = s;
            this.$rootScope = h;
            this.init() } return n.prototype.init = function() { var n = this;
            this.$scope.uiState = { isEdit: !1, isValidDayEnabled: !1, isShowErrorMessage: !1, isGiftCertificateValid: !1, isNewWxEnabled: this.$rootScope.isNewWxEnabled };
            this.getPagedGiftCertificatesList().then(function() { n.getReferralConfig().then(function() { n.$scope.referralConfig.actionType == n.enums.ReferralRuleActionType.GiftCertificate && n.getGiftCertificateById(n.$scope.referralConfig.rules[0].level1ActionData2).then(function() { n.setStatus(n.$scope.giftCertificate, !0) }) }) }) }, n.prototype.getReferralConfig = function() { var n = this,
                t = this.$q.defer(); return this.referralSvc.getReferralConfig(this.enums.ReferralRuleType.TotalPayment).then(function(i) { var r = i.data;
                n.$scope.referralConfig = r ? r : { isEnabled: !1, validDayCount: -1, actionType: n.enums.ReferralRuleActionType.Point, enabledRuleType: n.enums.ReferralRuleType.TotalPayment, startDate: new Date("2001-01-01"), rules: [{ ruleType: n.enums.ReferralRuleType.TotalPayment, condType: n.enums.ReferralRuleCondType.TotalPaidAmount, level1Benchmark: 0, level1ActionData2: 0 }] };
                n.$scope.referralConfig.startDate || (n.$scope.referralConfig.startDate = new Date("2001-01-01"));
                n.$scope.uiState.isValidDayEnabled = !1;
                t.resolve(!0) }), t.promise }, n.prototype.getPagedGiftCertificatesList = function() { var t = this,
                n = this.$q.defer(),
                i = { status: ["已发布"], type: this.enums.CardType.GiftCertificate, pageIndex: 1, pageSize: 1e5 }; return this.$scope.enableGiftCertificates ? n.resolve(!0) : this.membershipSvc.getPagedGiftCertificatesList(i).success(function(i) { var r = [];
                i.items.forEach(function(n) { n.count - n.drawCount > 0 && moment(n.validStartTime).format("YYYY-MM-DD") <= moment(Ares.today()).format("YYYY-MM-DD") && moment(n.validEndTime).format("YYYY-MM-DD") >= moment(Ares.today()).format("YYYY-MM-DD") && r.push(n) });
                t.$scope.enableGiftCertificates = _.sortBy(r, function(n) { return n.count - n.drawCount }).reverse();
                n.resolve(!0) }), n.promise }, n.prototype.getGiftCertificateById = function(n) { var i = this,
                t = this.$q.defer(); return this.membershipSvc.getGiftCertificateById(n).success(function(n) { n && (n.leftCount = n.count - n.drawCount);
                i.$scope.giftCertificate = n;
                t.resolve(!0) }), t.promise }, n.prototype.setStatus = function(n, t) { if (this.$scope.referralConfig.actionType == this.enums.ReferralRuleActionType.GiftCertificate) { if (this.$scope.errorMessage = "", n) { var i = moment(n.validEndTime).format("YYYY-MM-DD");
                    n.isInactive == !0 ? this.$scope.errorMessage = "该优惠券已被删除" : n.isOfficeNotAvailable ? this.$scope.errorMessage = "该优惠券诊所不可用" : n.state != "已发布" ? this.$scope.errorMessage = "该优惠券状态不是已发布，状态为：" + n.state : n.count - n.drawCount <= 0 ? this.$scope.errorMessage = "该优惠券库存为：" + (n.count - n.drawCount) : (moment(Ares.today()).format("YYYY-MM-DD") > i || moment(Ares.today()).format("YYYY-MM-DD") < moment(n.validStartTime).format("YYYY-MM-DD")) && (this.$scope.errorMessage = "该优惠券不在有效期内，该优惠券有效期 " + moment(n.validStartTime).format("YYYY-MM-DD") + " 至 " + i) } else this.$scope.errorMessage = "不存在该优惠券";
                this.$scope.uiState.isShowErrorMessage = this.$scope.errorMessage && t;
                this.$scope.uiState.isGiftCertificateValid = !this.$scope.errorMessage } else this.$scope.errorMessage = "", this.$scope.uiState.isShowErrorMessage = !1 }, n.prototype.formatReferralConfig = function() { var n = this.$scope.referralConfig,
                t;
            this.$scope.uiState.isValidDayEnabled || (n.validDayCount = -1);
            n.startDate = moment(n.startDate).format("YYYY-MM-DD");
            t = { isEnabled: n.isEnabled, ruleType: n.enabledRuleType, condType: this.enums.ReferralRuleCondType.TotalPaidAmount, actionType: n.actionType };
            _.each(n.rules, function(n) { n = _.extend(n, t) }) }, n.prototype.save = function() { var n = this; if (this.$scope.referralConfig.rules && this.$scope.referralConfig.rules.length < 1) { this.aresConfirmDialog.warn({ message: "请填写激励规则" }); return } if (this.$scope.referralConfig.rules[0].level1Benchmark <= 0) { this.aresConfirmDialog.warn({ message: "累计消费金额应该大于0" }); return } if (!this.$scope.referralConfig.startDate) { this.aresConfirmDialog.warn({ message: "请填写计算开始日期" }); return } if (this.$scope.referralConfig.actionType == this.enums.ReferralRuleActionType.Point && this.$scope.referralConfig.rules[0].level1ActionData2 <= 0) { this.aresConfirmDialog.warn({ message: "激励积分应该大于0" }); return } if (this.$scope.referralConfig.actionType == this.enums.ReferralRuleActionType.GiftCertificate && this.$scope.referralConfig.rules[0].level1ActionData2 <= 0) { this.aresConfirmDialog.warn({ message: "请选择优惠券" }); return } this.formatReferralConfig();
            this.referralSvc.setReferralConfig(this.$scope.referralConfig).success(function(t) { n.$scope.referralConfig = t;
                n.$scope.uiState.isValidDayEnabled = !1;
                n.aresNotification.success("保存成功");
                n.$scope.uiState.isEdit = !1;
                n.$scope.initTooltip();
                n.$scope.setStatus(n.$scope.giftCertificate, !0) }) }, n.prototype.cancel = function() { this.init() }, n.prototype.edit = function() { this.$scope.uiState.isEdit = !0;
            this.$scope.initTooltip();
            this.$scope.referralConfig.actionType == this.enums.ReferralRuleActionType.GiftCertificate && this.$scope.initGiftCertificateDropDown(this.$scope.enableGiftCertificates, this.$scope.referralConfig.rules[0].level1ActionData2);
            this.setStatus(this.$scope.giftCertificate, !1) }, n.prototype.onCountChanged = function(n, t) { this.$scope.uiState.isEdit && (n[t] = parseInt(n[t]), n[t] < 1 && (n[t] = t == "validDayCount" ? null : 0)) }, n.prototype.setReferralRule = function() { this.appNav.goToState("scrmCenter", { action: "invite" }) }, n.$inject = ["$scope", "$q", "enums", "referralSvc", "officeOptionSvc", "membershipSvc", "aresNotification", "aresConfirmDialog", "appNav", "$rootScope"], n }();
    managementModule.controller("ReferralTotalPaymentConfigCtrl", Ares.tsController(n)) })(management || (management = {}));